Fog is essentially a cloud at ground level.
It forms when moist air cools enough that some of its water vapor condenses into tiny liquid droplets.
Air temperature matters
Air can contain water vapor, but the amount that can remain in vapor form depends strongly on temperature.
As moist air cools, it may eventually reach its dew point.
At that point, some water vapor begins condensing.
Tiny droplets stay suspended
The droplets are extremely small.
They can remain floating in the air rather than immediately falling to the ground.
When enough of them gather near the surface, visibility drops and you call it fog.
This is the same basic reason clouds can stay suspended.
How does air near the ground cool?
There are several routes.
The ground may cool overnight and chill the air above it.
Warm, moist air may move across a colder surface.
Air may be forced uphill and cool as it rises.
Different circumstances create different kinds of fog, but cooling moist air is the recurring theme.
Why does fog make it hard to see?
The tiny droplets scatter light.
Instead of light traveling cleanly from distant objects to your eyes, it gets redirected in many directions.
That reduces contrast and makes distant objects disappear into the gray.
Is fog made of water vapor?
Not the visible fog itself.
Water vapor is invisible.
What you see is liquid water in the form of countless tiny suspended droplets.
The same distinction matters with visible breath on a cold day.
Why does fog eventually disappear?
Air warms.
Wind mixes in drier air.
Droplets evaporate.
Once the conditions no longer support suspended droplets near the ground, the fog thins or disappears.
So fog is not mysterious vapor hanging in the air.
It is basically a cloud that formed where you happen to be standing.
And that’s the short explanation.
Related explanations: Why can you see your breath in cold weather?, Why do clouds stay in the sky?, and Why does glass fog up?