The heat that eventually causes the earth to warm actually comes from the sun. The sun is a huge ball of gases, mainly hydrogen. Every day, the hydrogen in the sun is converted into helium through millions and millions of chemical reactions. The by-product of these reactions is heat.
Reaching the Earth
The heat released from the sun's chemical reactions does not stay near the sun, but rather radiates away from it and into space. So much energy is released through the reactions that some of it still can reach to the earth, even though the earth is millions of miles away from the sun. The heat energy usually reaches earth in the form of light, and many of the sun's rays are in the ultraviolet spectrum. The transfer of heat in this way is known as thermal radiation.
Some of the heat energy from the sun bounces back off the earth's atmosphere, but some of it gets through and reaches the earth's surface. The energy that does reach the earth's surface warms it. The extra energy causes chemical reactions, which give off heat again as a by-product--this heat is released through the same process of thermal radiation. Some of the heat energy is trapped by the greenhouse gases in the atmosphere, and the temperature of the earth rises.