All organisms need to exchange certain gases with their environment. The primary gases tend to be oxygen and carbon dioxide. All organisms that perform aerobic respiration, the process where glucose and other food molecules are broken down for energy, require a regular supply of oxygen. So without oxygen, organisms would not be able to obtain enough energy to power their body processes. Unicellular organisms often absorb oxygen directly from the environment whereas multicellular organisms have a variety of adaptations that allow them to collect oxygen (e.g., gills, lungs, etc.).
One of the byproducts of cellular respiration is carbon dioxide (#CO_2#). One important note is that the carbon dioxide released by organisms does not come from the oxygen they breathe in, but from the food particles they break down. Carbon dioxide must be expelled from the body and again, organisms have a variety of ways to do this.
In photosynthesis, however, the organism requires carbon dioxide from the atmosphere. One of the byproducts of that process is oxygen, which comes from the splitting of water molecules.
A common misconception is that plants take in carbon dioxide and convert it to oxygen for animals to breathe. As previously stated though, the oxygen plants release comes from water, not carbon dioxide. Also, plants perform both photosynthesis and aerobic respiration.