In connection with the themes of deception, disguise, and performance, Twelfth Night raises questions about the nature of gender and sexual identity. That Viola has disguised herself as a man, and that her disguise fools Olivia into falling in love with her, is genuinely funny. On a more serious note, however, Viola's transformation into Cesario, and Olivia's impossible love for him/her, also imply that, maybe, distinctions between male/female and heterosexual/homosexual are not as absolutely firm as you might think.
The play stresses the potential ambiguity of gender: there are many instances in which characters refer to Cesario as an effeminate man. Even more radically than this, however, it also suggests that gender is something you can influence, based on how you act, rather than something that you are, based on the sexual organs you were born with. Twelfth Night also shows how gender-switches make the characters' sexual identities unstable. For instance, at times, Olivia seems to be attracted to Cesario because "he" is such a womanly-looking man, while Orsino at the end of the play seems as attracted to Cesario as he is to Viola.
Gender and Sexual Identity ThemeTracker
Gender and Sexual Identity Quotes in Twelfth Night
If you will lead these graces to the grave
And leave the world no copy.
And call upon my soul within the house;
Write loyal cantons of contemned love
And sing them loud even in the dead of night;
Halloo your name to the reverberate hills
And make the babbling gossip of the air
Cry out 'Olivia!' O, You should not rest
Between the elements of air and earth
But you should pity me.
An elder than herself: so wears she to him,
So sways she level in her husband's heart:
For, boy, however we do praise ourselves,
Our fancies are more giddy and unfirm,
More longing, wavering, sooner lost and worn,
Than women's are.
As it might be, perhaps, were I a woman,
I should your lordship.
Orsino: And what's her history?
Viola: A blank, my lord. She never told her love,
But let concealment, like a worm i' the bud,
Feed on her damask cheek: she pined in thought,
And with a green and yellow melancholy
She sat like patience on a monument,
Smiling at grief. Was not this love indeed?