The Redditor theorizes that whoever had the lamp before Aladdin wished first for unlimited wealth (wouldn't we all?) and then wished for the magic carpet in order to see the world and spend their wealth uninhibited.
Then, having fulfilled those two wishes, the lamp-holder wished the Cave of Wonders into existence in order to hide the lamp.
Here's where Aladdin fans started to split on the theory: Did this lamp-holder create the cave to ~welcome~ a future user, or to keep everyone out?
On the one hand, only the "Diamond in the Rough" could even enter the cave at all, so maybe the lamp-holder came from a similar background as Aladdin and wanted another "street rat" to inherit the lamp.
As the Redditor puts it: "So for his final wish he wanted to share his fortune with someone who deserved it. As a final wish, 'I wish that after I die all my possessions (including the lamp) be locked away until someone deserving comes along to take it, someone who otherwise would have never had a chance. A diamond in the rough.' Thus creating the cave of wonders and an eternal defender awaiting the right person to come along."
On the other hand, the entire cave collapses if you try to grab anything other than the lamp, so maybe the lamp-holder just wanted to keep EVERYONE out.
Normally, you would assume this was the final test: The true heir to the lamp would have to forego all the treasure in order to get the lamp. But if you had to be the "Diamond in the Rough" in order to get inside at all, why punish a poor street rat who could use a little gold to buy food?