Shakespeare scholars believe that Twelfth Night, or What You Will was commissioned by Queen Elizabeth I as part of the Twelfth Night celebration held at Whitehall Palace on January 6, 1602. The occasion of the celebration was the end of the diplomatic service to Elizabeth's court of Don Virginio Orsino, Duke of Bracciano.
Perhaps Shakespeare hoped to honor or flatter the Duke by naming the character of Orsino after him. Hopefully, the real Duke Orsino had a good sense of humor about being portrayed as the impulsive, lovelorn Orsino in Shakespeare's play.
The title of the play might have been inspired by the occasion for which it was written, that of Twelfth Night, which might have inspired Shakespeare to write a play that reflected the title of the play as well as the occasion.
Aside from the Twelfth-Night traditions of women dressing as men, role-playing, and the general upsetting of societal norms, there's no reference in the play to Twelfth Night, Epiphany, or anything related to Christmas, although the subtitle, What You Will, is entirely appropriate to the play.
Shakespeare seems to have taken advantage of the opportunity to bravely and boldly satirize some individuals in Elizabeth's court, which was something Shakespeare might do with impunity only at Twelfth Night, when servants could be masters and the rules of social order and decorum were suspended for the occasion.
It's believed that Shakespeare's Olivia represented the Queen herself, who could be fun and even flirtatious but was undeniably brave and steadfast as well.
The character of Malvolio is thought to be a caricature of Sir Christopher Hatton, Elizabeth’s steward. Sir Christopher was meek, toadying, and submissive to Elizabeth (and at one time, he apparently attempted to woo her) but mean-spirited and overbearing to Elizabeth's servants and courtiers, who found him foolish and ridiculous and mocked him behind his back.
As for the business of Malvolio's famous yellow stockings and cross-gartering, Lacey Baldwin Smith writes in Henry VIII, The Mask of Royalty that when Henry VIII received news of the death of his first wife, Catherine of Aragon, he "celebrated with a masque, banquet and ball where Henry, cross-gartered in yellow hose, danced the night away with Anne Boleyn.”
Shakespeare might have been able to claim deniability for any correlation between Elizabeth's court and the characters in Twelfth Night by setting the play in far-off Illyria, in the Balkan Peninsula, across the Adriatic Sea from Italy in what is present-day Croatia, Bosnia and Herzegovina, and Albania.
The title, Twelfth Night, likely represents Elizabeth's commission and the occasion for the play's performance, and the subtitle, What You Will, reflects the content and tone of the play itself and Shakespeare's apparent carefree abandon in writing it.