The early Earth was very unstable. The first atmosphere was made by volcanic eruptions. The gases carbon dioxide, methane , water vapour and ammonia were released and made up the first atmosphere.
The Earth slowly cooled over billions of years. The water vapour in the atmosphere cooled so the water condensed, which caused it to rain for 1million years. This created oceans and lakes. The water in these, absorbed carbon dioxide gas.
In the oceans, algae and microscopic plants evolved. These plants were able to photosynthesise so oxygen was released by them into the atmosphere . Carbon dioxide gas levels began to fall and the levels of oxygen began to rise.
Ozone gas was formed from the oxygen in the atmosphere. This created the ozone layer which blocked out most of the harmful UV rays from the sun. This lead to larger plants and animals evolving.
250 million years ago an atmosphere like the one today was created. The atmosphere today is mainly nitrogen (79%), oxygen (21%), carbon dioxide (0.03%), traces of argon and water vapour
Today, burning fossil fuels is causing carbon dioxide levels to rise. Carbon dioxide is a greenhouse gas and can lead to Global warming of the Earth.