When the Earth first formed the atmosphere was mostly hydrogen and helium, the same stuff out of which Jupiter, Saturn, and the Sun are formed. As volcanos erupted over the Earth's surface and the light gases escaped into space, that atmosphere gradually changed to carbon dioxide and sulfur dioxide. These gases, in turn, eventually got absorbed into rocks, leaving an atmosphere dominated by nitrogen, with some carbon dioxide. The first lifeforms to evolve on Earth used carbon dioxide and gave off oxygen as a byproduct. Over millions of years these single-celled organisms changed the atmosphere, taking in carbon dioxide and returning oxygen. As lifeforms increased in numbers and complexity, the process accelerated until oxygen made up approximately 20% of the atmosphere like it does today. For more on the evolution of the Earth's atmosphere click here.