The theme of madness in Twelfth Night often overlaps the themes of desire and love. Orsino talks about the faculty of love producing multiple changing images of the beloved, similar to hallucinations. Olivia remarks at certain points that desire for Cesario is making her mad. These examples of madness are mostly metaphorical: madness becomes a way for characters to express the intensity of their romantic feelings.
But the play also has multiple characters that seem to go literally mad. As part of the prank that Maria, Sir Toby, and Fabian play on Malvolio, they convince everyone that he is crazy. The confusion that results from characters' mixing up Viola/Cesario and Sebastian, after Sebastian's arrival in Illyria, also leads many of them to think that they have lost their minds. The general comedy and chaos that creates (and results from) this confusion also references the ritualized chaos of the Twelfth Night holiday in Renaissance England.