The Internet you mentioned at the top of your comment saw its roots as a DARPA project called "ARPANET". That's right, it was a Department of Defense project.
During the Cold War and the Space Race, the military was heavily tied with "general science and technology research". Aerospace, materials, you name it, if it had some sort of military application it was looked into.
So yeah, war sucks and the military might waste money in some projects but it's unwise the look at military and science in black-and-white, this-or-the-other terms.