Rosencrantz and Guildenstern were summoned by the King and Queen to find out why Hamlet is not acting like himself -- why "the exterior not the inward man / resembles that it was." They want to know if it is more than his father's death that has brought about this change. The King specifically suggests that they "draw him on to pleasures, and to gather / so much as from occasion you may glean."
Rosencrantz and Guildenstern do the best they can to discover what is going on with Hamlet, but very quickly, Hamlet becomes suspicious of their motives and asks them directly, "were you sent for or no." When the two don't respond directly, he dismisses their friendship.
In a wonderful play of irony, they tell Hamlet that they passed a troupe of actors on their way to Elsinore. Hamlet decides to have these actors perform a play that he has changed to mirror how Claudius killed King Hamlet. He hopes that King Claudius will reveal his guilt.
When Rosenerantz and Guildenstern take the message to Claudius about the play, Claudius seems pleased and says,
with all my heart, and it doth much content me
to hear him so inclined.
Good gentlemen, give him a further edge
And drive his purposes on to these delights.
Claudius doesn't realize that if the play goes as Hamlet hopes, Claudius will be doomed.