The Earth emits infrared radiation. This is absorbed by gases in the atmosphere called greenhouse gases: methane, water vapour and carbon dioxide. These absorb the radiation emitted by the Earth and prevent it from escaping into space. This greenhouse effect keeps the Earth warmer than it would otherwise be, and the temperature gradually increases over the decades.
Remember the Moon and Earth are the same distance from the Sun. The Moon has no atmosphere and an average surface temperature of –18°C, while the Earth has an average surface temperature of 14°C. So you can see that greenhouse gases are not a bad thing in themselves - they keep us from freezing! The concentration of greenhouse gases is increasing, leading to global warming.
[ This page has been adapted from www.bbc.co.uk/schools/gcsebitesize/science