I believe that they did deserve their deaths. They were supposed to be Hamlet's friends, but were helping the King and Queen spy on Hamlet. Though they characters aren't developed that thoroughly, they seem quite willing to work against Hamlet in order to gain favor with the King and Queen. Even if they didn't know that they were taking Hamlet to his death, they were aware that they were betraying their close friend.
On the other the hand, one could also argue that they didn't deserve their deaths on the basis that they were following orders from the king. They do share their concerns about Hamlet's health, and so it could be argued that they were attempting to act in his best interest.
I don't think they deserved execution! They were compelled to report to the king and queen on Hamlet's lunacy. They were sent for and told to keep an eye on him for Hamlet's own good. They believed Hamlet was going nuts and that he needed care and support. They did not reveal anything secretive or dangerous to the King and Queen. They did not 'make love to their employment' as Hamlet claimed. They did not know of the King's plan to murder Hamlet. They believed they were acting in Hamlet's best interests.
R+G were blind pawns that got swept up in a murderous power struggle. Hamlet interpreted the worst motives in their actions with no just cause.
HORATIO: So Guildenstern and Rosencrantz go to't.(60)
HAMLET: Why, man, they did make love to this employment!
They are not near my conscience; their defeat
Does by their own insinuation grow.
'tis dangerous when the baser nature comes
Between the pass and fell incensed points(65)
Of mighty opposites.