I guess what you can conclude from both stories is: wealth makes you incredibly dumb. Ali Baba was pretty clever when he was getting his hands on the robbers' loot, but by the second story, he had become just as clueless as the robbers.
And yeah! Those two robbers who were imprisoned for their stupidity. I'm thinking the first few days no one shows up, the cave was echoing with: "Hellllllooooooooo? Anybody out there? Someone let us out. HELLLLLLLOOOOOOOOO...." And then after some time pass, the caves fall silent, until Ali Baba shows up and says, "Well, no one here. I'm good!"
Wow...that's...really morbid.