> Then why don't we set the focus distance to be the nearest as
> possible, as this will achieve the maximum depth of field?

Because it won't. If you focus on a point closer than the hyperfocal point, then the depth of field gets shorter. Infinity is no longer in focus.

> So the best would be to focus on the object at 0.4m, as it will cover
> 0.2m to infinity

No, it would cover 0.3m to 0.6m. The depth of field quickly gets shorter when you focus on a point closer to you.