NPR recounts the history of the cake dating back to Old World Europe. The French and the Spanish brought the cake to the Americas, where it seems to have been adopted in Catholic influenced areas from New Orleans to Mexico.
The traditional colors of Mardi Gras, which include purple (justice), green (faith) and gold (power) adorn the cake. A token, notably a plastic baby symbolizing the infant Jesus is hidden inside.  The lucky eater who finds the baby (hey, try not to eat it!) may be crowned king or queen of the party.
Of course, royalty comes with obligations. Find the baby and you're responsible for bringing the cake to the next gathering. Feeling adventurous?  Make David Gaus' King Cake recipe.