In Shakespeare's Hamlet, Hamlet is in the first four scenes of Act Four to give Claudius reason to send him away (in terms of the play's structure). Hamlet has killed Polonius, and Claudius realizes that it could have been him. Hamlet plays his "insanity" game, leading the King's men, especially Rosencrantz and Guildenstern, on a merry chase to find the body of the King's dead advisor. It is not until scene three that Hamlet finally relents and advises them where the body is. Now Claudius has good reason to send Hamlet away, and he tells him that he is doing so for his own good.
It is in this scene that we learn that Claudius has sent a letter with Rosencrantz and Guildenstern (who travel with Hamlet) to deliver to England's king, asking that Hamlet be executed (as a favor to Claudius). Scene four shows a chance meeting with Fortinbras' army and Hamlet, giving Hamlet another reminder that he must act, with honor, to avenge his father's death.
I believe that it is Hamlet's absence that allows Ophelia to lose her sanity. If he had seen her worsening condition, he might have been able to help. If nothing else, he could have kept an eye on her to make sure she was kept safe. With Hamlet out of the picture, and Polonius dead (though he doesn't seem a particularly caring father who forever sends his daughter out to spy for him and the King), only the Queen can act as an advocate, and even that is not enough. Of course, in terms of the play's structure, once Polonius, and then Ophelia die, Laertes—with some help from Claudius—believes Hamlet is to blame. The final scene that abounds with villainy and tragedy is set in motion with the death of the King's advisor and his daughter. Shakespeare clears the way for all of the remaining characters in the play to be killed by the King's treachery.