There is perhaps no single factor that has proved to be as important in the US space program than was the cold war between the US and the USSR. Space programs were begun in both nations at roughly the same time, however initially the USSR put much more resources into developing their space program than did the US.
The international atmosphere due to the cold war can be seen as a catalyst that finally spurred the US into action, lest the US ended up looking weak or stupid. Further, the technology gained through the space program had the potential to shift the military balance of power.
By the time that John Kennedy announced his plans, in the early 1960’s, to put a man on the moon by the end of the decade, the US was lagging behind the USSR in space technology. It is very interesting to note, from a historical perspective, that John Kennedy was totally uninterested in space. His reasoning was that the US “had” to beat the USSR to the moon. But that determination almost came too late.
The USSR launched the first satellite, Sputnik, into orbit in 1957, prompting the formation of NASA by President Eisenhower, but it still took about four months for the US to launch it’s first satellite, and before doing so, there were quite a number of embarrassing failures. Then in 1961, Soviet Cosmonaut Yuri Gagarin became the first man in space. A little over 3 weeks later, the US launched Alan Shepard into space.
As the people of the US became aware that the USSR was out pacing them in technology, which they’d fairly well believed that the US was superior in up until that point, support for a fully funded space program began to grow rapidly. This allowed the support necessary for the Kennedy and Johnson administrations to virtually give NASA a blank check to fund the space program. And with the public behind the idea of space exploration, NASA began to make great strides forward, eventually to the Gemini and later to the Apollo programs.
Meanwhile, the Soviets had their successes, but also their failures including with their moon probe program, and it was the latter that buoyed the sentiment at NASA. Then, in 1968, James Lovell, Frank Borman, and Bill Anders became the first men to orbit the moon, and for the first time since the space race started, the US was finally in the lead.
US astronaut, Neil Armstrong became the first person to set foot on the moon on 21 July 1969, after landing a day earlier.
It is doubtful that this could have happened, had it not been for the cold war that actually encouraged both nations to “keep up with the Joneses”.