In addition to its performance near the actual Twelfth Night, the Elizabethan Christmas tradition of "twelfth night" was much like today's Mardi Gras - completely topsy turvy mindless fun. This is why there is cross dressing, servants attempting to woo their superiors, general light-hearted mayhem, the party boys Toby and Andrew, and the fool, Feste, who is actually the smartest character in the play.
The Twelfth Night festival chose a commoner to be king for twenty nine days (and on the thirtieth killed him). Malvolio's dreams of becoming a noble echo this (and he too, gets punished).
Twelfth Night is also called the Feast of the Epiphany, and the play (arguably) ends with an epiphany.