A greenhouse is an ideal environment for plants to grow. Its clear walls let sunlight in, and then trap the heated air inside. Life exists on Earth because our planet is like a giant greenhouse. Earth's atmosphere absorbs and holds heat from the Sun through a process called the greenhouse effect.
To see a model of how this works, make your own miniature greenhouse or "terrarium" out of a clear container. Of course, Earth doesn't work exactly like a terrarium. A terrarium's solid walls contain warm air inside it. But the atmosphere is not a solid barrier. The gases in the atmosphere absorb some of the heat radiated from Earth's surface, and then re-emit some into space and some back towards Earth's surface.