In the beginning, at the time of evolution of the planets, the earth was also a body of burning clouds of gases and dust. After cooling process, the heavy elements subsided downwards and the gases floated upwards and formed the atmosphere around the earth as a blanket.