It was a tight battle, but in the end the party managed to pull out a victory. Sure, the mage will need to rest for 8 hours to be useful again and the cleric is down to one cure light but the enemy is vanquished and the room is clear. Now for the treasure! Gold is found and even a couple of magic items; that certainly explains how one of the enemy was able to set the fighter on fire. The party seals up the room and starts dividing up the loot.
So ends another adventure. Now the question is...who does the treasure belong to, the characters or the DM?
The obvious answer is the characters. They just "earned" it by defeating the enemy. The treasure is their reward for the risks involved in obtaining the treasure. The players risked their characters in pursuit of the treasure.
And yet...the DM has the right to take it away at any point in time. The DM can have thieves steal it, tax collectors take their cut, dragons eat it in exchange for the characters lives, it can be "dropped" during stressful situations. Basically, there are hundreds of ways a DM can part the characters from their treasure.
But should a DM do such things?
I will agree there are times when the characters and their treasure have to part ways. When a DM messes up and gives the characters treasure that can disrupt a campaign, such as far too much gold or a magic item that gives the characters too powerful an advantage, then sure, take it away. But at this point the DM is really doing nothing but redressing a mistake they made.
Ultimately it is the DM that gives over any treasure the characters gain. Sure, the DM might roll on a random table and let the die roll determine what the treasure is, but the table does not talk. The table and dice do not tell the players what treasure the characters gain. The DM is the one who gives the characters the treasure. The DM is making a decision at this point of the process. It is at this moment, the moment when the DM tells the players what the characters found for treasure, that the DM has to make a judgement call of whether or not the characters should get the treasure.
And once the characters have the treasure, they should be allowed to keep it. They earned it. There are few things in rpgs more frustrating than to have your characters struggle over great odds and have nothing to show for it. That will be how they will look at it if a DM keeps taking away the treasure they have gained. While treasure is not often the driving goal of a campaign, it is still a measuring stick of advancement and progression. Treasure is the representation of achievements.
If the DM is running a gritty, survive-on-the-most-meager-of-resources type of campaign, then it falls on the DM to hand out the treasure that stays within that concept. It is better to hand out no treasure than to give out treasure and then take it away.
What do you think? Do players have an innate right to keep the treasure they loot or is it always at the whim of the DM?