The first level explanation is simple. Air can hold a certain amount of water. The amount is less at lower temperatures. So, if the temperature drops, the air may not be able to hold as much water as it did at a higher temperature, and dew forms. Whether dew forms is a question of the humidity of the air, and the temperature.
Another way to talk about this is relative humidity. If we specify a temperature, we can talk about relative humidity at that temperature as a percentage. This is a percentage relative to how much water the air could hold at that temperature. As temperature decreases, the relative humidity will increase. When we drop to the dew point temperature, the relative humidity becomes 100 percent, the air is saturated with water, and dew forms.
I find the dew point temperature to be more informative. For a given body of air with a certain amount of water in it, the dew point temperature is constant. The relative humidity is changing all the time whenever the temperature changes. Getting both concepts straight means you have gotten your head properly wrapped around all of this.
The question though is, "how can something like a tent or sleeping bag get cooled below the temperature of the surrounding air?" Anyone who has camped outside much has experienced this on a clear night when they awaken to find their sleeping bag covered in dew. The clear night is a vital component, and it all has to do with infrared radiation.
Whenever two objects are at different temperatures, heat will be transferred by infrared radiation from the hotter object to the cooler object. This happens all of the time. This is happening right now as your body (at 98.6F) radiates infrared to cooler objects all around it (unless of course the objects around you are above 98.6F, in which case they are radiating heat to you.)
Space is very cold. On a clear night, all objects are radiating heat into space as infrared radiation. If that heat is not replaced (typically by conduction for objects in contact with the ground), their temperature will drop. An object that is isolated from heat sources (like blades of grass, tent flies, the top of your sleeping bag) will drop in temperature below that of the surrounding air, and if that temperature is below the dew point, condensation will occur.
The observant person has certainly noticed that after a night when dew or frost formed on their gear, other objects have no dew at all. There can be two reasons for this. Some objects (like rocks) are either in contact with the ground (which stores a lot of heat) or are massive enough themselves to hold enough heat to replenish their losses. Another factor is that different objects and materials have different infrared emissivity. Those with higher emissivity will lose more heat and drop in temperature more.
Similarly if your sleeping bag is under a tarp, or even a tree, the tarp or tree is a barrier to heat loss by infrared radiation into space, and dew is unlikely to form.
But if the air is really humid, even under a cloud or tarp, the air mass may cool below the dew point, yielding fog and dew on everything.
The following discussion is good, albeit almost unreadable due to terrible web page design choices:
Tom's hiking pages / tom@mmto.org