A greenhouse gives plants a glass covering which serves two purposes: it conserves the energy they get from the sun and it keeps the air temperature up. The atmosphere surrounding our planet acts the same way.
Only a tiny fraction of the heat and energy produced by the sun ever reaches the earth. And that heat would only be strong enough to keep our earth temperature at 30° below zero Fahrenheit.
Luckily, this heat does not escape into outer space; it is absorbed by the water vapor and gases of our atmosphere. As it bounces back and forth between the earth’s crust and the outer atmosphere, this heat gives off enough energy to keep our planet’s average temperature a healthy 60 degrees F.