Earth's atmosphere - you can say is like a greenhouse. A greenhouse is place where it can maintain a stable temperature on it. It is the same with the Earth's atmosphere. Outer space is very harsh environment. The pressure out there is almost nothing and temperature - mostly through radiation process - could vary from 200 to -100 degrees Celsuis. Now that's where the atmosphere comes in. The main purpose of the atmosphere is to maintain global atmospheric pressure and at the same time stabilizes the overall temperature of the Earth's atmosphere.
Now here are the functions of all the major gases in the atmosphere:
Oxygen/Nitrogen: Well, eventhough they sum up to 98%, the fact is, they have no contribution to the control of Earth's atmosphere. However, they do have one very important function in the atmosphere - Oxygen and Nitrogen and there sheer size is what's responsible to the stable atmospheric pressure. They keep the earth pressurized at all time. Although it has nothing to with the greenhouse effect, it is these gases that allows other gases to do there functions.
Water Vapor: Among the greenhouse gases - this one is the greatest among them all. Water has a very high specific heat - allowing it to absorb a lot of heat. But that's not the only thing water vapors do - white clouds. So what. Here's the main deal. Its all because of albedo effect - black absorbs heat, white reflects heat. And yes, clouds are the glasses of our greenhouse Earth. They reflect most of the infrared radiation from the sun back to space, or, reflects some of them back to Earth.
Ozone: well, this gas is what responsible why Earth isn't barbequed by ultraviolet and xray radiations. This gases absorbs or reflects this radiation back to space. That's why, the ozone layer is a very important greenhouse gas, because not only x-rays and ultraviolet radiations is bad - they are more energetic than infrared radation could ever be, which could heat up the atmosphere even more.
Carbon Dioxide and Methane: These two gases are what's responsible to that cozy and comfortable warm atmosphere. These two gases are what absorbs most of the heat and prevents them from reflecting it back to space. However, too much of this good stuff, and it burns. The more carbon dioxide there is to Earth, the hotter the atmosphere could be, and heat means more energy which means more powerful storms, or faster melting of the polar ice because of a hotter ocean. But, there is amore potent greenhouse gas than carbon dioxide, and that is - methane. Methane gas is very efficient in storing heat, and it is 23x better than carbon dioxide in terms of heat absorption. Thankfully, there's noy methane in the atmosphere.
Hope my answer helps you.