At any temperature, air can hold a certain proportion of water. As temperature increases, air can retain more water, and as temperature decreases air can hold less. typically water is absorbed into the air during the day when temperature is high. During the night, the temperature may fall below the point at which all the water in the air can be retained. Condensation takes place as excess water condenses on the ground.
Air pressure also affects how much water air can retain. Air at high pressure can retain more water. It is no coincidence that high temperatures and pressures is associated with dry sunny days, and low temperatures and pressure is associated with wet dull days.
When talking about the water content of air, 'relative humidity' is useful. 40 humidity means that the air has 50% of the maximum water it can retain, without condensation taking place.
Areas close to water - sea and lakes - typically have higher humidity than inland areas. Water is readily available, and the different rates at which water and land rise and falls creates breezes and increases evaporation and so humidity.
At other times, winds can decrease humidity because of windchill, which can lower the temperature in open regions below the level at which the amount of moisture in the air can be retained.