This is part of the process of photosynthesis, where plants use sunlight, water, and carbon dioxide to produce their own food (sugars) and release oxygen as a byproduct.
Humans and other animals breathe in oxygen and release carbon dioxide as a byproduct of respiration, the process of using food to produce energy.
This exchange of gases is a crucial part of the Earth's ecosystem, ensuring a balanced cycle of oxygen and carbon dioxide.