To understand the science of global warming, we can start by looking at a greenhouse. Essentially a small house made of glass, a greenhouse allows the sun's energy to pass through easily while inhibiting the heat from leaving. The Earth's atmosphere works in a similar way. A majority of the sun's radiation passes through the cloudless atmosphere and acts to warm the Earth's surfaces and the oceans. In turn, the land and ocean give off energy that is headed out to space. Most of this energy does not escape to space, rather it is absorbed by naturally occurring greenhouse gases such as water vapor (H2O), carbon dioxide (CO2), methane (CH4), and nitrous oxide (N2O). After they absorb the Earth's energy, they, in turn, re-emit some of that energy back toward the Earth's surface and provide additional warming of the Earth. This is what we call the greenhouse effect because, although the sun's energy is able to pass through the greenhouse gases, these same greenhouse gases trap the Earth's outgoing energy.
It turns out that greenhouse gases play a very important role in our climate system. Remove all the greenhouse gases in the atmosphere and the Earth's average temperature would be a very chilly 0 degrees F (-18 degrees C), and most of the planet would be frozen. However, in a manner similar to putting blankets on to trap your body heat when you go to bed, the layer of greenhouse gases acts as a blanket to keep the Earth a comfortable temperature of 59 degrees F (15 degrees C). And just as you can expect to sleep warmer if you add extra blankets to your bed, you can expect the Earth to get warmer if you add extra greenhouse gases to the atmosphere. So where are these greenhouse gases and how many of them are around? Well, take a deep breath. You have just inhaled an assortment of molecules that primarily include nitrogen and oxygen, and also small amounts of greenhouse gases such as water vapor and carbon dioxide. It's actually these molecules in relatively small concentrations, which exist everywhere in the atmosphere, that turn out to be important for shaping our climate. (You can now exhale!)