According to legend, the Carnival of Venice began after the military victory of the Venetian Republic over the Patriarch of Aquileia, Ulrico di Treven in the year 1162. In honour of this victory, the people started to dance and gather in San Marco Square. Apparently, this festival started in that period and became official during the Renaissance.
https://en.wikipedia.org/wiki/Carnival_of_Venice
Another take:
https://www.stlyrics.com/songs/p/phantomoftheopera21134/masquerade953593.html