Malvolio's function in this comedy is more difficult to evaluate. Certainly, on a basic level, he functions as a contrast to the merrymakers, Sir Toby and Sir Andrew; he is a somber shadow of the aristocratic world and a sober reminder to Feste that the world is a serious place. While the other characters are almost always happy, Malvolio is grave. He emphasizes the importance of dignity, decency, decorum and "good order"; yet when he thinks he sees a chance for advancement with Olivia, he abandons all such proper conduct and behaves like an utter fool.
Early in the play, Maria characterizes him as a puritan. He is always dressed in the black, puritanical costume of the puritan of that time — a person whom most people in this play would despise. Yet he is respected by Olivia, and she does wish to retain his good services.
It is Malvolio's ultimate egotism which makes him an easy prey for the pranksters. Before they leave the forged, fake letter from Olivia for him, he is walking in the garden, daydreaming about the pleasures and the powers he would have if he were married to Olivia. Thus, his own sense of conceit makes him an easy dupe for the trick that is played upon him. Even though the ruse is rather harsh, the audience dislikes anyone so opposed to having a good time.