When Hamlet first enters the cemetery he is merely hiding out with Horatio waiting for the most opportune moment to return to the castle to confront Claudius. In the cemetery they see a gravedigger preparing a grave. Hamlet has no idea that this will be Ophelia's grave in a few mere moments.
As he comes forward to talk to the grave digger he first comments about the nature of the business of grave digging, but he pretty quickly starts into a conversation about Hamlet, acting as a common man who just has a few questions about the Prince and what has happened to him lately. Hamlet asks, "Why was he [Hamlet] sent into England." The grave diggers reveals the story that has been put out about Hamlet -- that he has been sent to England to "recover his wits there." But the joke comes in the next sentence when he adds that if Hamlet doesn't recover his wits there "'tis no great matter there." When Hamlet asks why it wouldn't matter there in England, the grave digger says, "'Twill not be seen in him there. There the men are as mad as he." Shakespeare is making the joke that England is filled with crazy people -- so crazy that craziness isn't even all that remarkable. His audience would have certainly laughed at the self-deprecating joke.