Wikipedia provides a good summary including the lyrics from the song of that name.
Basically, Christians celebrate for 12 days after Christ is born, not before. The 12th day after Christmas (6th Jan) is called ‘Epiphany’. It is likely that this period was chosen by the Christian church to usurp pre-christian solstice celebrations. Evidently Shakespeare’s play ‘Twelfth Night’ refers to the 12 days of Christmas.
it was a crime to BE a Catholic in England 1558 thru 1829.
The song “The Twelve Days of Christmas” was possibly a Mnemonic used in England to help young Catholics learn the tenets of their faith. This carefully avoided written material that could lead to imprisonment or executed in very nasty ways. Though these tenets do not appear different from those of the Anglican church.
Codes used in the song include
True love = God
Me = Baptised person
Partridge in a pear tree = Jesus on the cross
2 Turtle Doves = The Old and New Testaments
3 French Hens = Faith, Hope and Charity, the Theological Virtues
4 Calling Birds = the Four Gospels and/or the Four Evangelists
5 Golden Rings = The first Five Books of the Old Testament, the “Pentateuch”, which gives the history of man’s fall from grace.
6 Geese A-laying = the six days of creation
7 Swans A-swimming = the seven gifts of the Holy Spirit, the seven sacraments
8 Maids A-milking = the eight beatitudes
9 Ladies Dancing = the nine Fruits of the Holy Spirit
10 Lords A-leaping = the ten commandments
11 Pipers Piping = the eleven faithful apostles
12 Drummers Drumming = the twelve points of doctrine in the Apostle’s Creed