I believe the current HMS Enterprise is a military oceanographic vessel that (among other things) conduits hydrographic surveys. Knowledge of the oceans is quite important to military activities.
Exactly my point: the Navy conducts scientific research because it helps support its military mission.
Starfleet conducts military missions because it helps support its scientific mission.
It's a "cart before the horse" type thing: in the military, the horse pulls the cart. In Starfleet, the cart is being used to transport the horse.
And that is most likely Starfleet's primary mission.
Starfleet's primary mission is exploration and scientific research, according to every Starfleet officer
ever.
By contrast:
Disagree, it's exploration that is one of Starfleet's secondary mission
According to no officer ever.
Captain of the Voyager says:
Commander Chakotay and I have agreed that this should be one crew. A Starfleet crew. And as the only Starfleet vessel assigned to the Delta Quadrant, we'll continue to follow our directive to seek out new worlds and explore space.
And also:
PARIS: My father used to talk at length to us about the Prime Directive, once a year, like a holiday sermon.
JANEWAY: He considered it the guiding principle of space exploration.
^ Interestingly, it's also the guiding principal of Starfleet
Also:
CHAKOTAY: I don't know that it's fair for me to put my own personal curiosity ahead of the ship's priorities.
JANEWAY: We still haven't found the polyferranide we need to seal the warp coils. If these people have warp technology, they might be able to help us. Besides, we are in the business of exploring, aren't we?
Also:
JANEWAY: He told us that you were curious and went off to explore the galaxy. We're explorers too, but your friend brought us to this quadrant against our will, and we haven't been able to find a way back.
Also:
JANEWAY: This is a ship of exploration, Mister Tuvok.
Captain of the Enterprise says:
What's the mission of this vessel, Doctor? To seek out and contact alien life, and an opportunity to demonstrate what our high-sounding words mean. Any questions?
He also says:
This is the Captain. We're on a difficult mission, but it's not the first time. Our orders do not say stay alive or retreat. Our mission is to investigate.
The Captain of the Enterprise-D says:
We are not invaders. We are explorers.
And also:
We're out here to explore, to make contact with other life forms, to establish peaceful relations but not to interfere. And absolutely not to destroy. And yet look what we have just done.
And also this:
PICARD: What do you want of us?
ALIEN: The same as you.
PICARD: Mister Barclay?
BARCLAY: You're both on the same mission, Captain.
PICARD: Mission?
BARCLAY: Yes, sir. The Cytherians are exploring the galaxy just as we are. The only difference is that they never leave their home. They bring others here. Their only wish, an exchange of knowledge. They want to know us.
Boothby says:
PICARD: You could use a good herbicide instead of pulling the weeds with your bare hands.
BOOTHBY: And you could explore space on a holodeck instead of a starship.
Crusher says:
CRUSHER: And the exploration of space? Surely that must count for something.
PICARD: I wouldn't trade it for anything, and I would still make the same choice I made all those years ago.
Lt. Commander Data says:
The Enterprise is not a ship of war. It is a ship of exploration.
Captain Ben Sisko says:
We are constantly searching, not just for answers to our questions, but for new questions. We are explorers. We explore our lives, day by day, and we explore the galaxy, trying to expand the boundaries of our knowledge. And that is why I am here. Not to conquer you either with weapons or with ideas, but to co-exist and learn.
Major Kira says:
DAX: There doesn't seem to be any immediate threat, Major.
KIRA: Oh, no. I'm sure all you Starfleet explorers find this fascinating, but I'm a Bajoran administrator. This is not what I signed up for.
The galaxy wide consensus among Starfleet officers and others is that Starfleet's primary purpose is exploration. It's not their secondary mission, it's not "something we do because the military can do lots of different things." It is the REASON why Starfleet exists; it is WHAT THEY ARE.