There's no reason to believe zero sum economics is anything more than a fallacy in a post-scarcity economy. There just aren't enough scarce things to explain their value. The economy has never been explained sufficiently, anyway. So the idea that joining civilizations are paying for their turn at the grand replicator of life doesn't entirely ring true.Just because they're fictional doesn't make them any less significant within the confines of the universe. They've been shown to be hard to find, difficult - even pernicious - to extract and process, and of finite quantity. That's like the definition of scarcity. Hell, they dedicated a whole film to the potential catastrophic and existential repercussions of a society losing its main source of dilithium.
And, as I always point out when one of these silly arguments arises, you can't replicate dilithium or deuterium or whatever the hell else the wegottafindit of the week is.
Which brings us back to J.'s initial point. To maintain the illusion of paradise on Earth, the Federation has to get that stuff from somewhere. They're passing the buck. So while a dumbass on Earth who broke his arm orbital skydiving can transport into any corner clinic and get it mended for "free," someone is paying the tab. And those usual "someones" are the newly embraced societies with whom the Fed extends a hand of friendship.
For all we could imagine, the Feds might use something like China's new Social Credit system. Risking life and limb in Starfleet might not appeal much to genteel Federation society, but it will get your ass in a nice Frisco condo with a view of the Bay, no questions asked, and you get to practically behave like a 19th century heathen while you're out there defending I mean doing science stuff for the federation. Even a screwballp like Barclay got the condo. Don't like it? There's always some grungy colony to go try and get a new start on civ building with. You may end up seeing half your colony wiped out by a madman when the harvest fails and Starfleet is two days late with the bread van, but you'll have tried. You will have tried.
The poor bastard vacuuming in the background in TWOK probably slept through school, farted on his only shuttle ride and posted rude comments about the Federation election on social media.