Photosynthetic life (plants and algae) produce oxygen as a waste product of taking carbon dioxide and water and using them to make sugars. This is the way we get oxygen in the air.