Water vapor exists as an invisible gas throughout our atmosphere. About 90 percent of this water vapor is added to Earth's atmosphere through evaporation from the oceans. When the sun heats the water in the oceans, some water changes from a liquid to a gas and rises in the warm air.
As water is heated by the sun, water molecules begin to move more rapidly. Some of these rapidly moving molecules manage to vacation free of the water below and escape as water vapor.
Air cannot hold an unlimited amount of water vapor. How much it can hold depends on the temperature of the air. Warmer air can hold more water vapor. When it reaches its limit, when the air can hold no more water vapor, then we say it is saturated, or has reached its saturation point. After this point, the water vapor will begin to condense back into a liquid.
This temperature point at which the water vapor begins to condense is called the dewpoint.
Dew is when water vapor condenses at ground level. Water molecules clump together creating droplets of water on surfaces. If surface temperatures are below freezing, the water vapor will form ice crystals instead of droplets. We refer to this ice formation as frost.
Condensation actually requires "dirty" air to occur above ground level. Our atmosphere is filled with microscopic materials like particles of dust and salt and suspended pollutants. These materials act as condensation nuclei, providing something for the water vapor molecules to clump approximately.
Fog is formed by condensation just above ground. Condensation at higher levels produces clouds. The process for each is exactly the same, so it is correct to think of fog as simply a cloud on the ground.