Well, with due respect to you and your service to the military, I don't think that your statement that "the military isn't dedicated to scientific exploration" is historically true.
What we need to take into account is that Starfleet isn't like the military now, in our day and age when the entire surface of the planet is known and quantified and the only mission objectives that a military has are of either a peacekeeping or warmongering nature..... no, Starfleet is instead like the military back in the golden age of sail, in the 17th and 18th centuries, when much of the world was yet to be explored, and the great military leaders were not just fighters and tactitians, but explorers and scientists as well. Bare in mind that two of the most important people in the militaries of old were the cartographers, whose job it was to map out the coastlines of strange new lands, and botanists, whose job was to, once landfall had been made, take samples of local flora and fauna for scientific study.
Basically, militaries have always had a primary objective of territorial expansion (as you put it, "war"). But their secondary objective, in the old days, included discovering more about the world, and adding to the collective knowledge of humanity. Charting 'the great unknown', as it were. Sounds a lot like Starfleet to me.![]()
This. 100% this. And Shawnster's example of the HMS Beagle is absolutely spot-on.