Eyeglasses fog up when they are cooled below the dew point and encounter warm, moist air. As they cool, water condenses out onto the surface of the glasses, creating the fogging effect. The same effect creates drops of water on the outside of cold beverage glasses.
The ability of air to hold water vapor depends on its temperature. The warmer the air is, the more moisture it can hold. When a volume of air cools quickly, it may not be able to hold all the water vapor present. When this happens, the water vapor condenses, forming a thin layer on surfaces. When water quickly cools high in the atmosphere, the condensation produces rain or snow.
Generally, eyeglass fogging should be a temporary problem. Once the glasses warm up to the ambient room temperature, they should no longer cause moisture to condense out of the air. There are also products which can prevent eyeglass fogging by creating a thin layer of material on the surface of the glasses that does not allow large drops of water to form. The anti-fog coating forces the water to condense evenly across the surface of the glasses, producing a layer so thin that it remains invisible to the naked eye.