The decorated ceiling of the cave where people
may have celebrated the Lupercalia, under the
Palatine Hill in Rome.
In the time of the kings of Rome, about 600 BC (and maybe even earlier), when the people of central Italy were all shepherds and farmers and lived in villages, they got cold and bored during the rainy winters and wanted to have some kind of party to cheer themselves up. At first people called this party Februa ("purification"), which is where we get the word February. Later people called it the Lupercalia.
In the early Republic, the Lupercalia took up three days, from February 13 to 15th. It was a festival of shepherds, and possibly the word Lupercalia has something to do with wolves, who eat sheep. The priests wore goatskins, and sacrificed two goats and a dog. Rich young men ran around the city without their clothes, hitting women with strips of the skins of the dead goats. The Lupercalia got rid of demons and got the city ready for spring planting, and for lambing, and generally for spring to come.
By the 100s AD, rich men in Rome weren't so much involved with farming, and they didn't want to do this anymore. Around the same time, people also stopped sacrificing animals at the Lupercalia, as animal sacrifice also went out of style. But thousands of regular people still celebrated the Lupercalia every year in Rome. The young men used cords instead of strips of goatskin. The custom of young men running around without their clothes, and a lot of drinking and funny songs, continued even after most people were Christians in the 300s AD.
In the 400s AD, Pope Gelasius finally made the Lupercalia illegal because it wasn't Christian. A lot of people complained, both that this was spoiling their fun, and that demons would come cause plagues and problems. The popularity of Mardi Gras celebrations may have begun about this time, partly as a substitute for the Lupercalia.