The atmosphere traps heat via the greenhouse effect, keeping the Earth's average temperature stable and habitable. Without it, the Earth would experience extreme temperature swings, becoming very cold, especially at night.