The sun emits electromagnetic radiation, of which infrared light and visible light pass largely unimpeded through our atmosphere and strike Earth’s surface and are converted to kinetic energy (heat). This heat slowly radiates back to the atmosphere where the heavier air molecules reabsorb some of the long wave infrared radiation, thus converting it back into kinetic energy once again. As the air molecule heats up, it re-emits infrared radiation in all directions. Some escape into space, the rest are reabsorbed and re-emitted again, etcetera. This process of thermal radiation keeps our biosphere from freezing over.
The quantum mechanics of absorption and emission is most easily understood by reading:
and by watching a short 5 minute video:
More about Greenhouse Effect in this blog (by relevance):