How were we able to measure carbon dioxide levels in earlier climates?
One method is through ice cores from the worlds ice caps.

Each year, as small amounts of snow accumulate on ice caps such as on Antarctica and Greenland, bubbled of air gets trapped.  As we drill through the ice, we can identify the air samples in those trapped bubbles, and measure directly the composition of the air in those bubbled.  It tells us much more than the level of CO₂.  For example, the ratio of isotopes of oxygen is a pretty good thermometer.  We can also see pollen, volcanic ash, and other things.

Other methods are listed at the Wikipedia article on climate proxies.  Most famous are ice cores and tree rings, but other methods are lake and ocean sediments, corals, and others.  Those methods are somewhat independent so if they confirm each other, that is good.  Errors on timing may get larger if one gets further back, and sometimes a new analysis leads too a change in timing estimates.  But for the period where we have comparable records (for example, the period for which written historical records exist), results compare pretty well!