As Hamlet is on his voyage by ship to England, his ship is attacked by a pirate ship. In the commotion of the ensuing impromptu battle, Hamlet ends up boarding the pirate ship. Once the battle has culminated, the pirates decide they will drop Hamlet off back in Denmark. Hamlet communicates all this to Horatio in a letter.
Also, Hamlet describes the pirates on the ship as "merciful," and the reader gets the sense that the pirates have agreed to let Hamlet go free with the suggestion that Hamlet is going to do some favor for them (after all, he is the prince of Denmark, so he presumably has some political pull!)
After a fierce fight, Hamlet manages to jump onto the pirates' ship who promise to take him back to Denmark in exchange of a favour Hamlet does not mention in the letter sent to Horatio. This is a time when the audience are to suspend their belief and ignore the fact that the jump is too much exaggerated and overlook the fact that Hamlet is actually helping pirates let alone calls them 'thieves of mercy'.