The Martian insects had lain dormant on their almost dead world, but when the probes from Earth spread algae fields across Mars it gave them a massive new food source and led to a population explosion. The Martian insects are what caused the algae to disappear, but in the process they actually gave Mars breathable oxygen levels, because they produce oxygen as a waste product (explaining why they are so flammable). The insects are also what destroyed the habitat module, as they tore in to get to the food supplies inside.
Burchenal explains to Gallagher that the biochemistry of alien insects' [[Respiratory system|respiratory metabolism]] is capable of producing oxygen far more efficiently than human science is currently able to. Studying the insects' biochemistry is the key to terraforming Mars, and may even lead to discoveries which will allow Earth's polluted atmosphere to be repaired. However, Burchenal is attacked by swarms of the insects when [[blood]] drips from an open wound. Rather than be eaten alive, he passes his sample vial of insects to Gallagher before himself and his attackers.
Gallagher reaches the Russian probe, finds sufficient fuel to power the rocket's engine, but not enough electrical power to launch the probe, and realizes that the only available replacement is AMEE's power core. In a final confrontation, Gallagher is able to lure AMEE into a trap and disable her using one of the probe's sample launchers, then takes her battery. Gallagher launches himself in the probe's sample-return capsule and reaches orbit where Mars-1 is waiting for him, and he is recovered and revived by Bowman.
Gallagher becomes upset that four astronauts died so that he may live, but Bowman tells him that they didn't die for nothing. The computer is busy analyzing the sample of Martian insects which Gallagher brought back, and research on them may lead to repairing Earth itself. With a six month long trip back to Earth, the computer has plenty of time to analyze the insects, and Bowman and Gallagher have time to start pursuing a romantic relationship.