Even though the setting of this scene is a graveyard, Shakespeare interjects some humor in the scene in order to relieve the tension of the previous act where Claudius and Laertes plot Hamlet's death and the coming end of the play where there will be inevitable deaths of at least some if not all of the main characters. There is a kind of "dark humor" in the fact that funniest person in the play is the man who digs graves for a living.
The pun you are referencing is in a conversation between the two gravediggers. A pun is a play onwords when two different meanings of a word are used together. The first speaker says that gravediggers hold up (continue) Adam's profession. He is referring to Adam (and Eve) the first humans. The second clown asks, "Was he a gentleman?" The pun starts when the first clown replies "The first that ever bore arms." He means had arms with which to work, but the second clown retorts, "Why he had none." He is using the second definition of arms -- meaning weapons. Clearly, Adam didn't have any weapons. The puns is extended when the first clown comes back to "his" definition and asks, "Are you a heathen? The scripture says Adam digged. Could he dig without arms?" This short scene is a clever and silly respite from an otherwise heavy and depressing situation.