Life on Earth first appeared in an environment rich in carbon dioxide. Some estimates place atmospheric CO2 as high as 97%.
Nothing on earth can live without CO2. It ia as indispensable as water.
All that CO2 was too much of a good thing. Living organisms had to develop adaptations to deal with it. The memory of those adaptations is still there in our DNA.
As life evolved, green plants appeared. All that CO2 got turned into oxygen. Animals appeared. They could use that oxygen. They still needed CO2, but they could make their own. As long as they were able to reproduce, they produced more CO2 than they knew what to do with, so they just got rid of it by flushing their lungs with fresh air. Soon that was the default breathing instinct.