Life on Earth relies on photosynthesis, the process by which plants, some bacteria, animals and protists like algae create their food. In order to photosynthesize, a plant needs sunlight, water and carbon dioxide; from this, it creates glucose, which is a form of simple sugar, and oxygen. The reaction involves six molecules of carbon dioxide (6CO2) and six molecules of water (6H20). In the presence of chlorophyll and light, this becomes (C6H12O6) and oxygen gas (6O2). Other organisms across the world use the oxygen created. The plant can use this chemical energy immediately or store it for later.
TL;DR (Too Long; Didn't Read)
Through photosynthesis, a plant, bacteria or protist creates oxygen, sugar from carbon dioxide and water, while in the presence of light.
Photosynthesis has two stages in a plant's leaf. The first, called a light-dependent reaction, takes place in the grana, a stack of tightly folded membranes in a structure called a chloroplast, which take in sunlight as a form of energy for use in the second stage. In the second stage, called the light-independent reaction, the plant uses this stored energy to convert the water and carbon dioxide into water and oxygen. In the case of anoxygenic photosynthesis, a process found commonly in bacteria, the creature releases no oxygen and uses sulfide, hydrogen or other organic substrates instead of water. Species that use anoxygenic photosynthesis, perhaps unsurprisingly, contribute negligible oxygen to the world's atmosphere.
The Human Side of Things
Humans, along with many other creatures on Earth, eat plants for chemical energy. Humans and these other creatures have a similar process to photosynthesis called cellular respiration; functionally speaking, it is photosynthesis in reverse. A creature ingests sugar (from a plant, potentially) and breathes in oxygen. It then releases carbon dioxide and water, and creates a form of chemical energy called adenosine triphosphate or ATP. As these are the molecules used in photosynthesis, scientists call these processes complementary. Without oxygen, this process becomes anaerobic respiration, or fermentation, which produces substantially less energy.
Sciencing Video Vault
The Earth's Atmosphere
In all, Earth's atmosphere weighs about 5.5 quadrillion tons, about 20 percent of which is oxygen. Photosynthesis plays a major role in maintaining oxygen and carbon levels across the world. That said, the bulk of photosynthesis, around 70 percent, is carried out by microscopic organisms in the ocean called phytoplankton, and Earth's tropical rain forests produce almost all of the remainder, around 28 percent. Urban forests in the United States alone create around 6.1 million tons of oxygen. However, human activity like logging and polluting jeopardize all of these oxygen-producing species.