Re: It was spent getting a dozen people to the moon and back instead
I'm not sure the moon landings were really done for the "betterment of mankind".
Yes the space program gave us loads of new technology and knowledge (as well as paying to train thousands of engineers), but we could have set out to get much of that knowledge with research and still saved all the funds spent on the hardware. All those medical sensors, for example, that were developed to monitor the astronauts could just have been invented by spending cash on medical research.
We do these things for a combination of prestige, "because we can", PR, idealism and progress - because we can't always know what technologies will actually be viable - until we've built them.
That's the thing with these kinds of projects. Some work and become essential, some work but fail commercially, some fail to get off the ground. It's not always easy to know what you'll get at the start, when you have so many problems to resolve, and you don't know if your solutions will be good enough or so amazing that the new technology changes the world.