When Viola arrives on the shores of Illyria after her ship sinks and she is separated from her twin brother (Sebastian), she decides to dress as a boy and get a job working for Duke Orsino, who thinks he's in love with the Countess Olivia. We don't know if Sebastian is alive or dead, especially given the fact that Olivia, too, is mourning the loss of her brother, who is most definitely dead.
This ain't your everyday, run-of-the-mill love triangle. Since Viola is secretly cross-dressed as a boy, "Cesario," and is supposed to be wooing Olivia on behalf of "his" boss, Duke Orsino, things get a bit messy. Poor Viola's life gets super-complicated when she realizes she's totally smitten with Orsino, who thinks she's just a pretty boy who happens to have luscious lips and a girly voice. To makes matters worse, Olivia falls in love with "Cesario" and has no idea that she's trying to sink her claws into the disguised Viola.
We're glad Sebastian's not dead, but when he decides to head over to Illyria, he causes a few problems because everybody thinks he's "Cesario" (who is actually his sister, Viola). In Illyria, Sebastian gets in a little dust up with Toby and Aguecheek and also marries Olivia, who is under the impression that she has successfully seduced Orsino's young page. When Viola (disguised as "Cesario") is confronted about Sebastian's actions, "he" denies everything, which makes Orsino and Olivia very unhappy.
Just when we think Viola is up a creek without a paddle, she comes face to face with her un-dead brother, Sebastian. This is awesome because the confusion about the whole "Cesario"/Sebastian mix-up becomes clear to everyone. But, Viola takes her sweet time revealing that she's not really "Cesario," which makes the climactic moment seem to drag on forever. When Viola finally reveals who she is, Sebastian is happy that his twin sister isn't at the bottom of the ocean. It's also now OK for Olivia to have been chasing "Cesario" because she can channel all of her passion into a relationship with Sebastian. Orsino is also free to hook up with the girl he thought was his pretty-boy page. Orsino and Viola will marry – just as soon as Viola changes out of her "Cesario" get-up.
Uh-oh. Things were going so well that we almost forgot about Malvolio, who has been locked up in a dark room and treated as though he's a lunatic and possessed by demons. (He's not – he's really just an annoying and judgmental party-pooper who has been tricked by Maria and Toby.) Malvolio, however, is not a happy camper and fails to see the humor of the situation.
Fabian confesses to Olivia that he, Toby, and Maria are responsible for the elaborate prank on Malvolio that tricked him into acting like a madman. This isn't really news for the audience, but it clears things up for Olivia and Malvolio. When Malvolio vows to seek revenge on the whole lot of characters, we begin to worry and feel kind of bad for the poor guy…but only for a couple of seconds.
OK, we know for sure that Viola and Orsino will eventually get married and consummate their love. In the meantime, Shakespeare leaves the ending a little ambiguous (kind of like "Cesario's" gender). You see, Viola can't change out of her boy clothes just yet, because her dress is being held for her by the sea captain, who is temporarily unavailable. (Malvolio is holding him captive somewhere.) Orsino says that, as long as Viola is dressed as a boy, she'll "be" "Cesario." It's not entirely clear what he means by this, but Shakespeare seems to invite us to make of it "what we will." You can check out "What's Up with the Ending?" and "What's Up with the Title?" if you want to read more about this.