Borrowing an explanation from one of my other answers, the basic mechanism of the greenhouse effect is roughly as follows (note this is also a simplified model)
The Earth is in (to all intents and purposes) a vacuum, so it can only
gain or lose heat via radiation. The sun emits most of its radiation
at visible and UV wavelengths. The Earth's ...