The Earth formed 4.5 billion years ago as a molten ball, and its early atmosphere consisted of gases like carbon dioxide and water vapor released by volcanoes. As the planet cooled, oceans formed from condensed water vapor. Algae evolved around 3.4 billion years ago and began producing oxygen through photosynthesis, causing oxygen levels in the atmosphere to steadily rise over billions of years. Modern animals later evolved to use oxygen for respiration.