I have an affinity for space exploration because in graduate school I studied coding theory, one of the essential technologies for communicating with deep space probes. It's fascinating how we can communicate with the Voyager 1 spacecraft that has only a 23-watt radio transmitter but is over 10 billion miles distant. That's right: we're talking the equivalent of one small lightbulb on the edge of the solar system. We will remain in contact with both Voyagers, launched in 1977, for another 10-15 years. At that point the nuclear fuel in their electrical generators will have decayed too much.
You might not know how important coding theory is. It arose from the work of mathematician Claude Shannon at Bell Labs in the 1940s. (How Bell Labs could afford to fund Shannon and its other spectacularly successful scientists -- 11 Nobel laureates in all -- is a blog for another day.) Shannon's work lept so far beyond the state of the art at the time that AT&T couldn't apply it. Starting in the late 1950s, however, the space program needed technologies to communicate with spacecraft. Space race dollars paid for the development of coding theory, largely by MIT guys, on top of Shannon's work.
50 years later, a range of products that make our modern lifestyle what it is -- CDs and DVDs, cellphones and WiFi, etc. -- would not exist without coding theory. I'm sure that coding theory would have progressed absent a space race, but it would have taken much longer. For the most part, I agree with NASA that space programs produce or at least accelerate technology that benefits humanity. It's certainly preferable to the argument that development of armaments similarly drives the advance of technology.
It's difficult to explain coding theory to non-mathematicians; Wikipedia tries to. But here's an easily understood and related question in mathematics: how many tennis balls fit inside a basketball? That's an unexpectedly profound and important question.