Think of the holiday entitled "Twelfth Night" as what a kid today would call "Opposite Day." This festival during Shakespeare's time was often enjoyed by practising role-reversal; hence, the characters in the play also seem to do the exact opposite of what they usually did in their day. For example, Olivia, a high-profile lady, pursues a younger male servant for her love rather than accepting the courtship of a Duke. Here she is not only the pursuer of the relationship, but also assumes an unaccustomed role for that time of choosing for herself a husband. She is in charge of her estate, which didn't happen in Shakespeare's time, and she seems to be able to afford to comfort of rejecting her social status by marrying beneath her class.
Other examples of role reversal are characterized in Viola disguising herself as Cessario, Malvolio becoming the fool, the Clown becoming the wise man, and Maria using her wits to create an intelligent practical joke rather than the men. Also, Sir Toby and Sir Andrew are supposed to be respectable knights, not commonplace drunkards who have forgotten their manners and their chivalry. Almost every character seems to act topsy-turvy according to their norm.
Act V fixes everything that was topsy-turvy, though. The true roles of each character's gender is revived and placed in the correct place. Viola is able to put her dress back on and assume her natrual personality; Malvolio is reestablished as a proper man and not a fool; Olivia is married to a real man; and Antonio is redeemed from his place as a prisoner. The Duke makes a statement at the end of the play that seems to sum up the idea that nothing is as it seems, but must be treated as such while playing (or wearing) the part:
For so you shall be, while you are a man;
But when in other habits you are seen,
Orsino's mistress, and his fancy's queen"