In the very final scene, we actually learn of a very surprising and poorly explained connection between Malvolio and the sea captain who rescued Viola. In the final scene, Sebastian and Viola see each other for the fist time since the shipwreck, both believing the other to have been dead. Since Sebastian knows he has never had a twin brother, he also knows who he is looking at must be his twin sister. She openly assures him that she really is Viola, thus disclosing her true identity as a woman. When Duke Orsino learns she is really a woman, he asks her for confirmation of the love she bears him that she repeatedly hinted at while pretending to be Cesario. When Viola swears that she certainly does love Orsino, he next asks to see her in her "woman's weeds," meaning woman's clothing (V.i.284). This is when we next learn that Viola will have some trouble getting her original clothes back from the sea captain she left them with because apparently he is now in jail due to Malvolio having had some grievance against him, as we see explained in the lines:
The captain that did bring me first on shore
Hath my maid's garments: he upon some action,
Is now in durance, at Malvolio's suit. (285-87)
What these lines are saying is that apparently at some point Malvolio had the captain brought to court on some unknown charge against him, and the captain is now in jail. But we don't ever learn exactly how the captain offended Malvolio, and this is the only place where any connection between the captain and Malvolio is brought up. The only other place in which the captain is mentioned is in the very first scene in which we meet Viola, Act 1, Scene 2, when she devices her plan to disguise her identity and asks the captain for assistance.
Hence, while apparently the captain and Malvolio have some connection in that the captain somehow offended Malvolio, we never actually learn what that offense was, making the connection both surprising and poorly explained.