Oxygen is the third most abundant element in the universe, according to the Thomas Jefferson National Accelerator Facility. However, its reactivity made it relatively rare in early Earth's atmosphere.
Cyanobacteria, which are organisms that "breathe" using photosynthesis, take in carbon dioxide and exhale oxygen, just like modern plants. Cyanobacteria were likely responsible for the first oxygen on Earth, an event grandly known as the Great Oxidation Event.
Photosynthesis by cyanobacteria was likely ongoing before significant levels of oxygen built up in Earth's atmosphere; a March 2014 study published in the journal Nature Geoscience found that 2.95 billion-year-old rocks found in South Africa contained oxides that would have required free oxygen to form. These rocks were originally in shallow seas, suggesting that oxygen from photosynthesis first began to accumulate in marine environments about half a billion years before it began to accumulate in the atmosphere around 2.5 billion years ago.
Life today depends heavily on oxygen, but the initial build-up of this element in the atmosphere was nothing short of a disaster. The new atmosphere caused a mass extinction of anaerobes, which are organisms that don't require oxygen. Anaerobes that were unable to adapt or survive in the presence of oxygen died off in this new world. [Infographic: Earth's Atmosphere Top to Bottom]
Fast forward — way forward. The first inkling humans had of the existence of oxygen as an element was in 1608, when Dutch inventor Cornelius Drebbel reported that the heating of saltpeter (potassium nitrate) released a gas, according to the Royal Society of Chemistry (RSC). The identity of that gas remained a mystery until the 1770s, when three chemists converged on its discovery more or less at the same time. English chemist and clergyman Joseph Priestly isolated oxygen by shining sunlight on mercuric oxide and collecting the gas from the reaction. He noted that a candle burned more brightly in this gas, according to the RSC, thanks to oxygen's role in combustion.
Priestly published his findings in 1774, beating out Swiss scientist Carl Wilhelm Steele, who had actually isolated oxygen in 1771 and written about it, but not published the work. Oxygen's third discoverer was Antoine-Laurent de Lavoisier, a French chemist who gave the element its name. The word comes from the Greek "oxy" and "genes," meaning "acid-forming."
Oxygen has eight total electrons — two orbit the nucleus in the atom's inner shell and six orbit in the outermost shell. The outermost shell can hold a total of eight electrons, which explains oxygen's tendency to react with other elements: Its outer shell is incomplete, and electrons are thus free for the taking (and giving).