FORMATION OF THE ATMOSPHERE
Earth lost all its air almost as soon as it formed. Most of the gas was hydrogen and helium, and Earth’s gravity simply wasn’t strong enough to hold it down. This meant that in the earliest days, there was no air at all.
Earth’s first atmosphere emerged from the belly of the planet. Gases bubbled up to the surface during violent volcanic eruptions, covering the ground in a hot blanket of carbon dioxide, nitrogen and water. Then came the rain. The water leaked out of the atmosphere in torrents that formed the first oceans, leaving nitrogen as the dominant atmospheric gas.
When life eventually evolved, the atmosphere changed again. Photosynthesising organisms pulled carbon dioxide from the air and split it apart, turning the carbon into food for their bodies and spitting the oxygen back out as waste. As that oxygen started to build up, ultraviolet light from the Sun shattered it into pieces. Those pieces recombined to make the ozone layer.