Oxygen was formed on Earth sometime around 2.7 to 2.8 billion years ago by the microorganisms like algae and cyanobacteria through photosynthesis.