Touch the inside surface of a window on a cold day and you can see that glass is lousy at keeping out cold.
Why, then, does glass work so well for building hothouses?
First, a few facts about heat and light, because what a greenhouse does is convert visible light into invisible heat.
When you look into a fire you see several different colors. You also feel the heat on your face. What you're seeing, and feeling is energy radiating from the fire. Some of that radiation has a relatively high energy level that shows up as blue, yellow, or red light. Radiation with an energy level lower than red light is called "infra-red radiation." You can't see infra-red radiation, but you feel it in the form of heat.
Radiation comes through the greenhouse windows, mostly in the form of visible light. This light is absorbed by objects in the greenhouse like leaves, rocks, and dirt. However, just as these objects absorb radiation, they also release it, which is why a brick wall may feel warm even after the sun is gone.
Radiation that is re-emitted always has a lower energy level than when it was first absorbed. Radiation absorbed as higher-energy visible light, may be re-emitted as low-energy infra-red light, or in other words, as heat.
The glass is important because higher-energy radiation, such as light, passes much more easily through glass than low-energy infra-red radiation. As long as the sun is out, the glass keeps the greenhouse warm by admitting the sun's energy as visible light, and then trapping it once it's been converted to heat.