In many of his plays, Shakespeare seems to go out of his way to remind the audience that it is watching actors on a stage and that we are all part of a larger drama taking place in the real world. To that end he uses asides and soliloquies wherein the actors seem to be clearly aware that they are players, and they communicate directly with the audience members.
That being said, the soliloquy and aside also serve another purpose. They give us clues to the character's personality and motivation, and they provide information that other characters in the play do not possess. In this way, they help us, as audience, to identify with the characters, thus engaging our attention and investing us in the outcome. We are privy to their private thoughts, so we are now invested in what happens to them.
Moreover, in a comedy like Twelfth Night, the asides and speeches let the audience in on the joke. For instance, we can watch Malvolio's rambling soliloquy about marrying Olivia alongside Toby, Andrew, and Fabian, hidden in the box hedge, and we become part of the action, too. Then we want to see him get what he deserves. Shakespeare has hooked us into his world, and we want to see the outcome.