The duping of Malvolio is linked to main plot thematically in the obvious sense that it deals with a variety of love, namely, self-love, a wholesale preoccupation with self-interest and a refusal to see anyone as important other than oneself. Such a preoccupation leads to a misconception of the world and a total vulnerability to being manipulated into betraying oneself, as Malvolio does, by trusting that one's desires match the reality of the situation. Malvolio is punished—and is relatively easy to punish—because he is so wrapped up in his own importance that he sees no value in anything else or anyone other than himself. His conceit about himself, along with his secret desires for social advancement and power, make him easy to tempt into ridiculous behaviour.
This point is made most obviously by the instant antipathy between Feste, the fool, and Malvolio. Malvolio sees no point in having a Fool around, especially one who seems as old and tired as Feste, in whose jokes Malvolio finds no amusement. It's important to note that the major motivation for the trick on Malvolio is the insult he makes to the Fool when we first meet them, together with his total dislike for any sort of fun.
Malvolio, in other words, is a kill-joy, a person with no sense of humour and with no place in his scheme of things for anything other than what he thinks is important. Everyone recognizes this. Olivia tells him he is sick of self love, and Sir Toby Belch roars at him