In short, it makes no sense to me and flies in the face of everything I've been taught. Now, I'm not a climate change denier. Actually, this is something I just now thought about. I've never really bothered to question it before.
The most important greenhouse gases are water vapour, carbon dioxide, and methane.
Source: gisgeography.com
Source: science of doom
Make sense so far?
Okay, Earth doesn't lose heat to conduction. Simply put, it's in a near-vacuum; there's not really anything its touching to transfer its heat to.
Instead, it loses its energy to radiation.
Now, objects emit radiation based on their temperature. So the energy coming from the sun? It's based on the temperature of the surface of the sun: about 6,000 Kelvin (about 10k degrees F). So the light/energy/radiation coming from it is very high-energy. That energy strikes earth and heats it up. But the Earth itself is comparatively cool: an average of 287 Kelvin (56 degrees F.) So the radiation that earth emits is much lower in energy.
And that's the key. Gasses like Carbon Dioxide don't allow lower-energy radiation to pass as easily has higher-energy radiation. So while it lets a lot of the sun's energy in, it doesn't let the radiated energy back out as easily.
Actually, the black part of the rod is still radiating, but in the infra-red part of the spectrum, which our eyes can't see. You may be familiar with infra-red cameras being used to measure temperature of people, or as a kind of night-vision. So this last picture from an infra-red camera shows that even "cold" objects like people are emitting radiation. [https://en.wikipedia.org/wiki/SGR-A1#/media/File:Thermal_image_-hand-_1.jpg]
So to sum up, the sun is hot (6000K) and emits light, which is mostly in the visible range. Visible light passes through the gases in the atmosphere and heats the earth up to 300K. The earth emits infra-red light which does not pass through Carbon Dioxide. So Carbon Dioxide traps some of the heat which would otherwise have radiated away from Earth. More Carbon Dioxide traps more heat, causing the temperature of the Earth to slowly rise.
*saying "the peak is in the visible range" is the easiest way to understand it, but the causality is round the wrong way. Our eyes evolved to have the highest sensitivity in the range where the sun produced the most light.