Climate is determined by a balance of energy flows into and out of the Earth at planetary scale. Most of the energy flow is accomplished by electromagnetic radiation: solar radiation heats the planet, infrared emission cools the planet. Because planets are surrounded by the vacuum of space, they can’t exchange energy with the rest of the universe by convection or conduction.
Earth’s atmosphere is selectively transparent to radiation of different wavelengths because of the presence of greenhouse gases (especially CO2 and H2O) with complex molecular structures. The selectively transparent atmosphere mediates energy flows, allowing most solar radiation to pass through but blocking the transmission of longer infrared waves emitted by the warm surface.