In the main plot, Duke Orsino uses the shipwrecked Viola, who is disguised as a man named Cesario, to help him woo the Countess Olivia. However, comic mayhem follows as Olivia instead falls in love with Cesario, not realizing, of course, that "he" is really a woman. That wasn't supposed to happen. Meanwhile Cesario/Viola falls in love with the Duke. So a woman falls in love with a woman disguised as a man, and a woman disguised as man falls in love with a man. It doesn't get much more gender bending than this. As Shakespeare said in another play, the course of true love never did run smooth though, this being a comedy, everything sorts itself out in the end.
The subplot involves servants. Olivia's servant Maria, called her "woman," wants revenge on Olivia's steward Malvolio, who has an inflated ego. Maria plays on this weakness, dropping love letters to him that are supposedly by Olivia. A steward with a more realistic self image would realize that a countess wouldn't fall in love with him, but the foolish and self-infatuated Malvolio falls for the scheme.
As is often the case in Shakespeare, the main plot involves highborn or aristocratic characters and the subplot lower-class characters. The subplot is linked to the main plot through characters such as Olivia but, more importantly, through the common themes of love, lunacy, and deception. Malvolio may be the one jailed for lunacy but, Shakespeare asks, isn't any form of love a kind of self-deceiving madness?