You're driving on a cold, winter day. You notice that you're windows are beginning to fog up. Why does this happen?
All About The Atoms
To get at what is going on here first we need to recall what the temperature of an object says about that object's atoms.
The atoms of any object are always in motion jiggling around, and the temperature of an object is a measurement of the average jiggling of that object's atoms: the hotter the object the faster the average jiggling of its atoms. If the temperature of air is dropped below a specific temperature, called the dew point, then the water vapor in that air condenses into a fog as the water molecules jiggle around slower and slower and eventually clump together.
This is why windows fog up in a car full of people on a cold day. Water vapor is first exhaled into the air by passengers in the car. Then because the car windows are colder than the dew point air close to the glass cools to below the dew point as well, causing water vapor in this air to condense and stick to the windows.
Raising The Temperature
So when you turn on the heater to warm up your windshield you are raising the temperature of the glass to above the dew point, where water molecules will remain quickly jiggling and not clump up, thus preventing your windows from fogging.
To defog your windshield you can also roll down a window, letting the moist air escape and letting drier air into the cabin. Or you could try not breathing, but this is not highly recommended.