When a car drives out of the factory, there may be tiny cracks in the pavement that the tires roll over easily. And, the road may go down into a small valley and up the other side, again causing no trouble for the car tires. But, if there is a pothole of the wrong size in the way, the tire may drop in, bending the rim, blowing the tire and getting the car stuck. Going really slowly might allow the car to ease through the pothole without damage, and going really fast might jump the pothole, but a car at the wrong speed in the wrong place can fall into the pothole and get into trouble.
We are all familiar with such situations, in which interactions happen when the size or energy is “right”, but otherwise there is almost no interaction. This is very common in the air. The shortwave radiation from the sun does interact with clouds, and the very shortwave (ultraviolet) interacts with ozone (which helps protect us from skin cancer caused by the high-energy radiation), but otherwise most of the light from the sun passes easily through the air. However, the infrared radiation going back up from the Earth does interact with certain gases in the air, which are often called greenhouse gases. Radiation tends to be absorbed if it is at or near those wavelengths with the right energy to make a particular molecule wiggle or spin in a particular way.
A molecule that is wiggling or spinning because it absorbed radiation has extra energy—it is hotter than it was. It usually will quit wiggling or spinning by colliding with a neighboring molecule and passing the extra energy along; occasionally, the extra energy will be sent out as radiation instead. Most of the energy absorbed by molecules in the air was going up from the surface, and if they “re-radiate” the energy it goes in a random direction, which has the effect of reducing the radiation going to space and sending some back to Earth. In the more common case of collisions, even a rare greenhouse gas can heat the atmosphere by repeatedly absorbing energy and then colliding with non-greenhouse molecules.
Without greenhouse gases, the Earth's average surface temperature would be well below freezing —about 18°C or -0.4°F.
Want to learn more?
Read over Enrichment titled The Simplest Climate Model to learn more about this.