Rosencrantz and Guildenstern are part of what is "rotten in Denmark." As old friends and former schoolmates of Hamlet's they, too, have their price. Thus, Claudius employs them to spy on Hamlet; however, Hamlet, detects their treachery. And, with his indefatigable wit, he toys with them, providing no information in his suspicions of them. He asks them what brings them to prison.
Prison, my lord?
Denmark's a prison.
Then is the world one.
A goodly one, in which there are many confines, wards, and dungeons, Denmark being one o' th' worst.
We think not, my lord.(2.2. 236-240)
When Hamlet asks them, "...in the beaten way of friendship, what make you at Elsinore?" (2.2.259), his old friends say, "To visit you,my lord; no other occasion" (2.2.2260) Hamlet knows that they lie. He tells them that there is confession in their eyes. Despite his knowing this, Hamlet confides that he has "lost all mirth." Speaking of his melancholy, Hamlet tells his old friends that "Man delights me not."
Still, knowing that they have been asked to observe him, Hamlet invites Guildenstern and Rosencrantz to watch the evening's play, knowing, of course, that he will implicate Claudius with the actions of the player king. His politeness to his old friends notwithstanding, Hamlet's ill feelings for them is apparent when later in the narrative, Rosencrantz and Guildenstern become subjects in Hamlet's counterplot as he is sent to England and they are killed.
Rosencrantz and Guildenstern are part of the theme of outside appearances as contradictory to one's inner qualities.
Rosencrantz and Guildenstern have been summoned to court by Claudius with one goal in mind--use Hamlet's childhood friends to try to get to the root cause of Hamlet's "madness." They are thrilled to be called to Court, as Claudius knew they would be. They are overawed by the King and are more than happy to do his dirty work--all in the name of friendship, of course. Hamlet sees right through their ploy and tells them nothing helpful, so they are rather worthless to either Claudius or their friend, Hamlet.