CAMBRIDGE, Mass.—Neil Armstrong hovered a few miles above the surface of the moon on July 20, 1969, searching for a safe place to make history.

Only minutes of fuel remained to land the first men on another world. A power meter failed in Apollo 11’s cramped lunar lander. Communications faded in and out. Then, warnings began flashing: Program alarm. Program alarm.

Five...