You can read a good explanation of it here. This is a great website for an overview of the physiology of exercise at altitude.
The basic idea is that, when you hyperventilate, you reduce the partial pressure of CO2 (carbon dioxide) in the blood. This allows more oxygen to diffuse into the blood as there is less "resistance."
But don't take it from me, I'm just someone who tries to digest this science. Here's a paragraph I'm taking from a respiratory physiology textbook from a course I took some years ago, called Respiratory Physiology, The Essentials by Dr. John West.
The most important feature of acclimatization to high altitude is hyperventilation. Its physiological value can be seen by considering the alveolar gas equation for a climber on the summit of Mount Everest. If the climber's alveolar PCO2 were 40 and respiratory exchange ratio 1, the climber's alveolar PO2 would be 43 - (40/1) = 3 mm Hg! However, by increasing the climber's ventilation fivefold, and thus reducing the climber's PCO2 to 8 mm Hg (see p. 16), the climber can raise his or her alveolar PO2 to 43 - 8 = 35 mm Hg. Typically, the arterial PCO2 in permanent residents at 4600 m (15,000 ft) is about 33 mm Hg.The point is, increasing ventilation (hyperventilating) can significantly increase the concentration of oxygen in the blood. This is why we naturally hyperventilate when going to altitude.
This is also why some high altitude residents chronically hyperventilate.