The purpose of the Luna class ships like the U.S.S. Titan was said to be something along the lines of
"after the Dominion War, Starfleet sought to return to exploration" or something like that IIRC.
It has always struck me that was very inappropriate.
More likely ships being built in the immediate aftermath of the Dominion War would be warships. Because Starfleet would be interested in replacing losses suffered in the fighting.
Here's one fundamental flaw in your logic:
Why assume it has to be one or the other? Why assume the
Luna Class is the
only one that was developed after the war? Obviously Starfleet's going to be rebuilding its defenses; that's so inevitable that it doesn't need to be pointed out. But a civilization needs more than military strength in order to survive. It needs to hold onto the principles it stands for.
Which leads to another fundamental flaw in your logic:
By your argument, it was "inappropriate" for the United States to invest in the Marshall Plan after WWII -- why spend all that money helping other nations, including our former enemies, rebuild when we could've spent it on building more ships and bombs to replace the ones we lost in the war? But history shows that it was very appropriate. By helping other nations rebuild, by investing in America's principles of peace and cooperation rather than investing solely in military strength, we strengthened our alliances, turned former enemies into new allies, and helped repair the economy and security of the broader world, which helped improve our economy and security as well.
The
Luna-Class exploration project isn't just about abstract scientific knowledge, though that's important too. It's about diplomatic outreach, about investment in good relations with neighboring civilizations, about reaffirming that the Federation is not a warlike state that its neighbors have to fear and attack. It does promote the Federation's security.
Also there's the economic consideration. The UFP may not have money, but that doesn't mean it lacks an economy, in the sense of an organized system for the allocation and distribution of resources and labor. A lot of the Federation's resources and labor clearly go into science, exploration, and colonization -- after all, there's not much else that people need to do for a living in a replicator economy. Just imagine how many people back home must devote their careers to analyzing the discoveries made by Starfleet explorers, to developing applications for alien technology, to arranging tourism and trade with newly contacted worlds, to settling or terraforming uninhabited planets, etc. etc. So promoting exploration promotes the UFP's economic recovery.