Scientists believe that earth was formed about 4.5 million years ago. Its early atmosphere was probably formed from the gases given out by volcanoes. The volcanoes gave out carbon dioxide and water vapor.
As the earth cooled down most of the water vapor cndensed and formed the oceans.
The first organisms in the ocean formed. They did not use oxygen as there was none. They then went on to photosynthesis.
Organism in the sea and plant start to photosynthesis taking carbon dioxide of the air adding oxygen.
A livable atmosphere is evertually fromed and the first big created are started to use to survive.
The burning of fossil fuels to create energy for homes and for transport are rapidly adding lots more oxygen to the atmosphere. Therefore the earth is warming and causing problems for the poles, melting ice.