How did CO₂ originate on Earth before there was life?
The answer is Volcanos. There might be other inorganic processes capable to produce $\text{CO}_2$, but on Earth, the main inorganic source of $\text{CO}_2$ are volcanoes.

In some period of Earth's history, there is evidence of large glaciations events, some of them are thought to have been triggered by the lack of $\text{CO}_2$ (like the Snowball Earth and Permo-carboniferous glaciations), and volcanoes are with no doubt the main candidate to have been responsible of restoring the warm climate by feeding large amounts of $\text{CO}_2$ into the atmosphere over millions of years.

$\text{CO}_2$ is an important component of rocky planets, but it is mostly dissolved (in large quantities) in the magma that exist (or once existed) in the interior of such planets. However, when the magma rises close to the surface, the drop in pressure reduce the solubility of $\text{CO}_2$ and it form bubbles of gaseous $\text{CO}_2$, that can then be expelled into the atmosphere trough volcanic eruptions, that in addition to teprha, and rocks include large amounts of volcanic gases of which $\text{CO}_2$ is one of the main components.
Probably that process of exsolution of $\text{CO}_2$ from hot molten rocks was happening even before the existence of volcanoes as we know them.

The same process happened once in Mars and Venus, whose atmospheres are composed mostly by $\text{CO}_2$ (96% and 96.5% respectively), suggesting that abundant $\text{CO}_2$ was also present in the early Earth's atmosphere.

Currently, it is estimated that volcanoes input to the atmosphere about 100 million tons of carbon in average per year in the form of $\text{CO}_2$, as illustrated by this NASA figure of the Carbon cycle:


(Originally from here)

You can see that many processes move carbon around, but the main reservoir by far is the crust, and that reservoir is tiny compared with all the $\text{CO}_2$ stored deeper in the Earth's interior.

Finally, in addition to be required by photosynthesis, $\text{CO}_2$ is part of the Earth's thermostat, that together with the silicate weathering have been key to keep the Earth's temperature in the range of liquid water. Arguably another very important need for the existence of life as we know it.