From Wikipedia:

The earliest known example of a bar joke is Sumerian, appearing in the form of two slightly different versions of a proverb inscribed alongside many others on two clay tablets[1][2] excavated at Nippur at the end of the 19th century. The tablets were etched around 1700 BCE,[3] during the Old Babylonian Empire, although Edmund I. Gordon, who published the first translation of most of the proverbs inscribed on these tablets, argued that the proverbs themselves probably date from a considerably earlier period.[4]

Scholars differ on how best to translate the proverb from Sumerian. According to Gordon's translation, the proverb reads: "A dog, having entered an inn, did not see anything, (and so he said): 'Shall I open this (door)?'"[4] The Assyriologist Seraina Nett provides a slightly different translation, suggesting that the proverb be read as "A dog entered into a tavern and said, 'I cannot see anything. I shall open this', or 'this one'".[3]

Solution: The joke is from the ruling class (priests) looking down on the ruled for being "unenlightened." Instead of the "dog" (label for non-holy in older cultures) opening it's third eye, it drinks. Because the "dog" (lower class) is spiritually blind, it spends it's life at the bar.