If the ground heat is lost, the temperature drops and the air is quite humid, then when it is cooled to a certain extent, some water vapor in the air will condense out and become many small water droplets suspended in the air layer near the ground to form fog.
Both it and clouds are caused by temperature drop, and fog can actually be said to be a cloud near the ground.