Gases in the atmosphere such as carbon dioxide do what the roof of a greenhouse does. During the day, the Sun shines through the atmosphere. Earth's surface warms up in the sunlight. At night, Earth's surface cools, releasing the heat back into the air.