Earth doesn't charge rent for using Earth as the Federation capitol, which if Trantor is any indication is a fair chunk of the surface, and they don't charge for the ships and starbase prefabricated pieces built on Mars... Although books say that Mars is also a Federation member world.
The value of free "unlimited" ships/space stations and an administration hub for both the Federation and Star Fleet, exceeds the cost of letting a hand full of Earther skalliwags taking fruit and sandwiches whenever they want to, while on holiday.
Shops request recompense from the local government, who are already drowning in resources from Earth donated with abandon, so these foreign worlds pick up the cost, since Earth's ledger is squarely in the black.
The trillions of plebs may not be tracking who owes what, but someone on Earth is, in a small basement with a half dozen accountants maintaining a very powerful computer, because everyone else in the Galaxy who uses money wants to get paid, and then the system will break down.