The Earth is thought to be about 4,600 million years old.
The Earth started with intense volcanic activity. The atmosphere consisted mainly of carbon dioxide, with small amounts of methane, ammonia, and water vapour.
The water vapour mainly consisted to form the ocean. There would have been little or no oxygen. This atmosphere was much like Venus or Mars.
The oxygen in the atmosphere resulted in the development of an ozone layer, which allowed the evolution of new living organisms.
1,000 years later, primitive life began that lived on these chemicals. Green plants evolved which make food for themselves using energy from the sun by photosynthesis.
The composition of the atmosphere has remained roughly constant. The amount of CO2 has remained stable due to processes that release it and remove it from the atmosphere being balanced. It has started to rise due to global warming.