There is still a gigantic opportunity cost of bringing together resources to produce an explosion rather then something more useful.
The old 'its going back into the economy' is some sneaky Keynsian language that only applies in certain macro economic situation and even that was mostly wrong and a misunderstanding of economic theory in the late 30s.
You can fund medical research without spending a million dollars sending a man to a desert, having his legs blown off, and flying him home. Hell, the US especially could actually use that research on civilians without bankrupting them!
And what about rebuilding bombed out cities? Is there so little else to improve?
It’s also a sociological trick. Societies support massive military R&D in ways that are impossible for public projects. We could wish upon a star that humans weren’t as we are. Or we can work with reality.
Military innovation is also historically a jobs program.
Check out how many states & companies are part of R&D/Manufacturing for the F-35.
The medical advances of military spending alone are breathtaking.