What is a greenhouse gas? The greenhouse effect is pretty simple: something prevents heat from escaping. In your actual greenhouse, it's the glass; it traps air inside the house, which is then warmed by the sun, and that heat cannot then escape. You might recall from your middle school days that there are three ways heat can move: conduction, convection, and radiation. The first involves the transfer of heat from one object to another by touch, the second involves moving heat by moving the hot object to a new location, the third keeps the object in one spot and lets it glow, sending heat in the form of radiation. A greenhouse blocks convection because the air is trapped inside, and it also blocks radiation because glass is typically opaque to infrared light (heat light). Conduction can happen, as the warm air inside the greenhouse can touch the walls, which can then touch the air outside, but air is such a piss-poor conductor of heat that that's fairly negligible.
A greenhouse is a perfect analogy because 1) our planet is surrounded by vacuum, making conduction impossible, 2) our gravity well holds on to our atmosphere rendering convection moot, and 3) our atmosphere contains IR-opaque gasses like the glass of a greenhouse. In fact, much of the reason our planet is warm is thanks to these greenhouse gasses: water, carbon dioxide, methane, and ozone. You'll notice that the majority constituents of our atmosphere, oxygen and nitrogen, aren't on that list. That's because of the way molecules work when it comes to infrared radiation.
Molecules move. They move in space as they whiz around; that's called translation. They also spin around: rotation. Finally, they can wiggle and jiggle: vibration. It's the vibration that's important, because vibrations can absorb infrared radiation. In fact, it's a class of vibration that absorbs infrared, and it's why greenhouse gasses are different from oxygen and nitrogen.
Let's take carbon dioxide as our example. Carbon dioxide can vibrate in four different ways, two of which are exactly identical, and three of which can absorb IR. (images stolen from this guy. If I understand blogger's kajigger right, then I'm hosting it here, so it's only stealing the image and not his bandwidth)
There's the symmetrical stretch, in which the two oxygen atoms move simultaneously and identically to/from the carbon.
There's the asymmetrical stretch, in which the oxygen atoms move simultaneously and identically to the left and to the right, while the carbon moves in the opposite direction to keep the center of gravity in the center.
Finally, there's the bend, in which the two oxygen atoms move up/down (or forward/back) while the carbon does the opposite, keeping the center of gravity still. There are two of these, and they're called a "degenerate" state because they're functionally identical, but mathematically distinct. If the backbone of the molecule is the z-axis, then these stretches lie in the xz plane and the yz plane.
This is where things get a little complex. Unless the two atoms of a molecular bond are identical (as in an oxygen molecule, where both atoms are oxygen) then they don't share the electrons of the bond equally. One will always pull harder on the shared electrons. In carbon dioxide, oxygen pulls harder and as a result it is slightly negative and carbon is slightly positive. Overall, this cancels out because the two oxygen atoms are opposite one another; think of it as two perfectly matched teams in a tug of war. But that situation changes when the molecule vibrates. In the asymmetric stretch, one of the bonds becomes longer and the other shorter, and the pulling is uneven. In the two bends, the oxygens are suddenly pulling in the same direction. Either way, the pull no longer perfectly cancels. Only in the case of the symmetric stretch, where the bonds remain perfectly equivalent, is there no change.
It's that change that's important. Any time there's a change in what's known as the dipole moment (the arrangement of those partial charges thanks to uneven sharing of electrons), then the vibration absorbs infrared light. Explaining the "why" of that would go beyond the scope of this post. Suffice it to say that carbon dioxide has three different ways to absorb IR, its two bends and its asymmetric stretch. Light comes in, the molecule absorbs it, and starts bending or stretching. The more light comes in, the more frantically it bends or stretches.
Still only half the story. Because the other half is that that light will eventually be re-emitted. The kicker is that it can re-emit the IR any which way. It might be up toward outer space, or it might send it back down toward the surface of the Earth (odds are roughly fifty-fifty). And that's why carbon dioxide is a greenhouse gas. It stops some of the heat coming up from the surface and sends it back down. The more carbon dioxide there is, the more likely this will happen. And this effect doesn't just happen once. Heat can get passed back and forth between the earth and our warm, snuggly greenhouse blanket any number of times.
That's why carbon dioxide (and water, and methane, and other molecules) are greenhouse gasses. That's also why oxygen and nitrogen are not. Every oxygen molecule is two perfectly identical oxygen atoms; they share electrons equally and no matter how hard it vibrates that will never change. Same for nitrogen. They'll never absorb infrared.
So how important is the greenhouse effect? We have an average surface temperature of about 14 centigrade, or 57 Fahrenheit. Without our atmosphere, it would be about -18 centigrade, or approximately 0 Fahrenheit. And that's with an atmosphere composed of roughly 1% greenhouse gasses. A lot of that is our atmosphere's ability to store heat in other ways, but I don't particularly want to stress the system. That is not how you test a bridge.