Condensation occurs when a vapor gas cools beyond its saturation limit and liquid begins to form. Because the water vapor releases its heat during this process, condensation is a warming process.
The arrangement of molecules in a vapor is random, and this randomness remains as long as temperatures remain high enough. As the vapor cools, clusters of molecules within it start to become less random. If the vapor cools enough, many of these clusters that form the vapor become too saturated and liquid condensation forms, usually on the nearest surface.
High in Earth's atmosphere the nearest surfaces available to cooling water vapor are tiny particles of dust and dirt. When enough water vapor condenses onto these particles, visible clouds form. In this way, condensation is a key part of Earth's water cycle; water from Earth's surface evaporates to form water vapor, which condenses into clouds and eventually falls again as rain.
Clouds are also play an important part in maintaining Earth's temperature. During the day, the condensed water vapor in clouds reflects excess solar radiation away from the planet's surface. At night, layers of condensation insulate the Earth and prevent heat loss; this is why a clear night sky often means a chilly evening.