The Earth was formed 4.6 billion years ago. The early atmosphere was densely formed with gases released from intense volcanic eruption. The atmosphere consisted of: Carbon dioxide, little or no Oxygen and small amounts of other gases such as methane and ammonia.
Volcanic activity released water vapour which condensed to form oceans. The water began dissolving gases such as ammonia-creating ammonia compounds and nitrogen containing substances. Nitrogen from volcanic activity was probably stored in the atmosphere because it is so unreactive.
2.7 billion years ago plants and algae began to build up in the oceans, carbon dioxide decreased in the atmosphere because it was being used in photosynthesis. Oxygen was released from the plants and entered the atmosphere. carbon dioxide + water → glucose + oxygen 6CO2(g) + 6H2O(l) → C6H12O6(aq) + 6O2(g)
Oxygen being present in the atmosphere enabled animals to evolve, putting Carbon Dioxide back into the air so it could be used in photosynthesis: glucose + oxygen → carbon dioxide + water C6H12O6 + 6O2 → 6CO2 + 6H2O
Today's composition of the atmosphere: Nitrogen-78%, Oxygen-21% Carbon dioxide-0.03%, Argon, methane and water vapour
Today burn fossil fuels and this increases the Carbon Dioxide levels in the atmosphere faster than it can be removed. We keep cutting down trees and killing plants and this decreases the amount of CO2 being used in photosynthesis.