The Greenhouse Effect helps to moderate temperatures -- especially nighttime temperatures. Without the greenhouse effect, the average temperature of the Earth would be -18 degrees C.
Greenhouse gases allow sunlight to pass through Earth's atmosphere, but as sunlight strikes the Earth it is partially changed to radiant heat. Greenhouse gases like carbon dioxide, water vapor, and methane help inhibit the escape of radiant heat back into space.
That is why the danger of nighttime frost is greater when the skies are clear than when skies are cloudy.