The theme of appearance vs. reality particularly helps create the comedy in Twelfth Night by adding both dramatic irony as well as verbal irony. Dramatic irony refers to moments when the audience understands far more about a character's situation than the character understands himself/herself. Verbal irony describes any time a character says something that he/she means to be understood in a way that actually contrasts with the literal meaning of what is said.
Viola embodies the theme of appearance vs. reality through disguising herself as a eunuch servant working for Duke Orsino when in reality she is an orphaned, wealthy noblewoman. We especially see how her disguise lends itself to creating dramatic irony when we see Olivia's response to Viola's disguise as Cesario. Viola as Cesario was particularly bold in gaining admittance into Olivia's home, making Cesario seem a bit surprising and mysterious. Cesario is also quite bold in confronting Olivia, even boldly criticizing her actions to her face, calling Olivia "the cruell'st she alive" (I.v.225). All of this boldness and mystery makes Olivia very quickly fall in love with who she thinks is Cesario, as we see in Viola's lines, "She loves me, sure; the cunning of her passion / Invites me in this churlish messenger [Malvolio]" (II.ii.21-22). What's more, the fact that Olivia having become so convinced by Viola's boyish disguise as to fall in love with her is a perfect example of dramatic irony because we the audience are well aware that Viola is really a woman, while Olivia is still unaware of the fact, and irony is a huge factor in creating comedy.
Viola's disguise also lends itself to moments when what she says can be seen as verbal irony, especially with respect to things she says to Duke Orsino. One example can be seen in Act 2, Scene 4, when Orsino sends for Feste to sing a song. While waiting for Feste, Orsino declares to Viola as Cesario that he bets Cesario's "eye / Hath stay'd upon some favour that it loves," meaning that he bets Cesario has fallen in love. Viola's brief response, "A little, by your favour," is an extremely ironic pun (II.iv.27). The phrase "by your favour" can mean "if you please," meaning that literally Viola is saying, "I have loved a little, if you please," which is a way of responding to her superior in a respectful way about such a personal topic. However, Viola is making a pun out of the phrase "by your favour" and using it to mean "near your appearance," which is a subtle way of saying, "Yes, my eyes have fallen in love with someone who looks like you." Hence, Viola's response is creating verbal irony by saying one thing and meaning another, and since the audience is well aware of what she really means because we are well aware that she is in love with Orsino, we see the comic effect that both her disguise, as well as the verbal irony produced through her disguise, are creating.