This article gives an in-depth picture of the use of money in the Star Trek universe. “Gene Roddenberry had a rule — one of those rules that the scriptwriters of Star Trek had to know and follow: in the Federation there is no money, period!”
Of course, money almost certainly has to exist. Trade is frequently portrayed throughout the show, and real-life societies have failed to come up with a functioning money-free society.
Even in the future, in a time of plenty, the laws of economics continue to exist.