How does this work?
The Greenhouse effect
There is a natural process called the ‘greenhouse effect’. It has been going on since Earth first formed. Sunlight reaches the earth, some of that energy coming from the Sun is reflected into space, while the other part of that energy is absorbed as heat in the atmosphere and radiated in all directions, warming the Earth. The gasses in the atmosphere that absorb the energy to produce heat are known as greenhouse gasses: carbon dioxide, water vapor, nitrous oxide, methane, and several others.
I don't want you to misinterpret this. In fact, you should be thankful for it. If it weren't for the greenhouse effect, then the Earth's average temperature would be 30 degrees lower (Fahrenheit). However, too much greenhouse effect can be very bad for us human beings. Venus is one example of too much greenhouse effect. "Venus has about 154,000 times as much carbon dioxide in its atmosphere as Earth," (NASA) As an effect, Venus has a surface temperature hot enough to melt lead. If Earth gets too much of that greenhouse effect, then the planet will warm.
GIF Credit: NASA/JPL-Caltech
Image credit: climate.nasa.gov