Shakespeare's Twelfth Night is a romantic comedy concerning the loves and adventures of two pairs of lovers, Sebastian and Olivia and Orsino and Viola. All of the protagonists are members of the upper classes and all are initially thwarted or misguided in their romantic endeavors, but eventually, after many plot twists, mistaken identities, and other entertaining episodes, both pairs of lovers end up happily marrying the right people.
Viola and Olivia are similar in that they are young, attractive women of the upper classes who appear to have recently suffered the loss of their brothers. Both are in love with people who seem unlikely to requite their love due to issues of gender. Both are concerned with the inner nature of their suitors rather than just wealth and power.
The main difference is that Olivia is portrayed as living at home, enjoying wealth and position under her own identity, while Viola has been shipwrecked and is disguised as a boy and employed as a page. Olivia's brother is actually dead, but Sebastian, Viola's twin brother, lives, and is frequently mistaken for Viola. Viola is in love with Orsino, but Orsino does not know she is a woman. It is only when her true identity is revealed that Viola can move from the position of page to wife, as Orsino sums up in the following passage:
Your master quits you; and for your service done him,
So much against the mettle of your sex, ...
And since you call'd me master for so long,
Here is my hand: you shall from this time be
Your master's mistress.
Olivia's attraction to Viola as a man is resolved when she ends up marrying Sebastian, Viola's male twin, and thus the true version of what Viola was merely pretending to be.