In order not to forget where they hid their goods, they naturally drew cards.
Treasure chests were buried not only by pirates of the Caribbean, but also by the inhabitants of the Middle Ages apparently in 1403 people did not trust banks even more than they do now (or they simply could not put their money and jewelry in them, since banks in the traditional sense of the word did not exist yet).