If a gas molecule vibrates at a particular rate, one of the molecules will absorb a certain amount of energy. It seems reasonable to say that 10 of the molecules will absorb 10 times more than one of them. So the more of a particular kind of gas molecule present, the more energy at a particular wavelength will be absorbed. There are no gases in the atmosphere that absorb energy at those wavelengths, so nearly all of that energy passes through like light through a window. The heating of the ground occurs for the same reason as when you shine a strong beam of light on something.
Energy striking an opaque object warms it up.
As the earth warms up, that heat energy tries to leave. Eventually, the heat emitted by the earth due to sunlight rises and passes out into space. But before the energy passes back into space it is changed. The law says that if you have two objects at different temperatures, the one with the lower temperature will emit radiation at longer wavelengths than the other. An inverse relationship.