About war: in our universe we got the first digital computers because of military efforts during the second world war. However, without a war IBM and Konrad Zuse and others would have gotten there, too. With much less human suffering.
Most US investment in associated tech - including the Internet - came through DARPA.
Not pointing this out because I support war, but to underline that the US doesn't have a culture of aggressive government investment in non-military R&D.
NASA and the NSF both get pocket money in budget terms. And at its height Apollo was a Cold War PR battle with the USSR that happened to funnel a lot of of money to defence contractors.
The original moon landings were not primarily motivated by science.
Private sector doesn't do much without obvious short-term gain, and it especially doesn't do basic research. It may be good at fitting more pixels in ever thinner phones, but it wouldn't get to that point if not the government that needed number-crunching machines for better modelling of nuclear fission some 80 years earlier.
Just don't spend tax payer money.
(And, if you don't like the monetary framing: just look at the real resources spend instead.)
However I'm not nearly as harsh on unmanned space exploration.
1) It's better aligned with mission profile (inspirational, emotional, but not strictly necessary;
2) There's much more of it to go than NASA gets;
3) It would be a better use of that money than what it's currently used for.
We'd get more and better science by spending it on unmanned space stuff. Or you could even just leave the money with the taxpayer.