Shakespeare's Twelfth Night, or, What You Will is one of the playwright's best-known comedies. The first known performance of the play dates from February 1602. Twelfth Night draws heavily on the story of Apolonius and Silla, a short story which forms part of a longer work, Riche his Farewell to Militarie Profession by Barnabe Riche. In addition, the play incorporates a number of themes based on the traditional celebrations of the holiday Twelfth Night.
In Tudor England, the holiday of Twelfth Night preceded the feast of the Epiphany and marked the end of the twelve days of Christmas. On the evening of January 5th, revelers marked the end of the festive season with special drinks and delicacies. Plays, music and games were an important part of the festivities.
One recurring element in Twelfth Night celebrations was inversion of the social order. Revelers would dress in outlandish clothes, often in outfits out of keeping with their social standing. Servants might take on the roles of masters while high-status individuals acted like servants. The chaos of the festivities did not last, however; at the end of the night society returned to normal.
Some of these themes appear in the play, which appears to have been written to be performed on this holiday. For instance, Viola, the heroine, dresses as a man and is mistaken for one. Similarly, the foolish servant Malvolio aspires to become a lord, dressing in ridiculous clothes in order to win the heart of the beautiful noblewoman Olivia.
In addition to these themes, Shakespeare took elements of the plot of his play from the story Apolonius and Silla, published by Barnabe Riche in 1581. In this tale, Silla, a young woman, is shipwrecked while pursuing the object of her affections. She dresses in men's clothes salvaged from the wreckage, and is mistaken for a man by a wealthy woman who falls in love with her.
The similarities between Twelfth Night and the tale of Apolonius and Silla continue when Silla's brother, Silvio, arrives looking for his sister, only to be mistaken for her. As in Shakespeare's play, the consequences of this mistaken identity eventually lead to the siblings' identities being revealed. Silla marries Apolonius, Silvio marries the wealthy woman, and all is resolved. The skeleton of the plot is very similar to Shakespeare's.
The tale of Apolonius and Silla itself draws on a lengthy tradition of mistaken identity stories dating back to the Roman theater. Plautus's comedy The Maenachmi similarly deals with mistaken identity between identical twins; it was the source of Shakespeare's The Comedy of Errors. Riche got substantial elements of his plot from a work in this tradition, an Italian play called Gl'Ingannati. It is possible that Shakespeare was also familiar with this work.