The question might be better answered if the goal were to find out if Maria was justified in playing such a mean joke on Malvolio. Did Malvolio really deserve being mocked and toyed with as he was? No. He may have been a bit conceited but to the degree and length to which Maria let it run, there was no reason for it. Maria let the joke go so far as to involve Malvolio's employer, Olivia! Then, she allowed it go to the point that Malvolio was locked up for madness. He didn't deserve to be locked up, for sure. Still, Maria's justification for toying with Malvolio is best described when she herself says the following:
The devil a Puritan that he is, or anything constantly, but
a time-pleaser; an affectioned ass that cons state without book and utters it by great swarths: the best persuaded of himself, so crammed, as he thinks, with excellencies, that it is his grounds of faith that all that look on him love him;and on that vice in him will my revenge find notable cause to work (II.iii.136-141).
To this end Maria justifies her actions. He's a "Puritan?" a "time-pleaser?" It sounds like Maria is jealous of Malvolio's loyalty to his job and the fact that he gets praise for it. She also doesn't like the fact that he is vocally declarative about his talents. Sadly, it all breaks down to a coworker squabble that goes too far and ends up completely out of hand. Maria could have let the joke go as far as Malvolio strutting around in yellow stockings and then reveal her plot to him in front of Olivia--that would have been enough. It sure makes for good comedy and drama, though.