This trap is a simple one, and works as a kind of psychological test for your PCs (and players).
The PCs adventure to a mausoleum filled with monsters, traps, and of course booty. Booty which is very specifically arranged. Upon defeating all the threats and obstacles, naturally they will want to leave with their loot… but the doors won’t open. (For high-level play, perhaps the entire tomb has been shifted sideways into a pocket dimension, so there’s nowhere to escape to. In this case, the tomb probably already has dimensional anchoring to prevent walls being bypassed, so a simple spell won’t suffice for escape.)
The only way to regain access to the outside world is to replace everything back where they got it, more or less precisely as you prefer. There’s no need to flag this fact – let the PCs sweat a while. You might lay some narrative pipe earlier in the piece by alluding to greed as a theme in the life of the person whose mausoleum it is, but that’s up to you.
Countermeasures depend on the nature of the trap. If it’s mechanical, a big block of stone in the doorway to jam the door open, or precisely-weighed bags of sand, might trick the mechanism into letting the PCs escape. If it’s magical, an anti-divination spell on each item to be stolen combined with a false magical aura spell on a substitute might do the trick. Conversely, an advanced portable hole capable of operating across planar gulfs might do the job if they’re prepared to leave one end behind… but maybe a magically isolated pocket plane could be a reward in itself, especially if you allow the PCs to customise it into their own personal domain. (Of course, this potentially means their home base might be haunted, which gives you some useful hanging plot threads.)
The name of this trap refers to an old method of trapping monkeys for eating – apparently, monkeys can work out how to get their hands into jars to get fruit, but aren’t quite smart enough to work out that they have to let go of the fruit to get their hand back out.