Shakespeare's whole purpose in having two men in these roles rather than only one is to show that Hamlet, although he is treated with respect, could be overpowered if necessary. Although Claudius doesn't say so, he thinks Hamlet is mad and possibly dangerous. He thinks this even before Hamlet kills Polonius in Gertrude's chamber. Afterwards, Claudius is sure Hamlet is mad and dangerous. If there were only one character guarding Hamlet, it would make Hamlet look weak. Shakespeare apparently did not want to show too many men guarding Hamlet, but only wanted to suggest Hamlet's restrained condition after he kills Polonius. With Rosencrantz and Guildenstern keeping close watch on their old friend, it is two against one. There is a suggestion that back-up is within call if Hamlet gets out of hand. When Rosencrantz tells King Claudius that Hamlet is
Without, my lord, guarded to know your pleasure
we understand that Guildenstern must be right outside with several assistants.
Although Hamlet is apparently a prisoner, he uses his wits to dispose of his captors and regain his freedom by sending them to England with a forged letter from Claudius ordering their immediate execution.