The success of this joke depends on the assumption of the Default Man. When Hamlet says “man” he means human because the sense, for time immemorial, has been that men are the standard humans and women are the deviation. So everyone always starts with man first – as in, is it a normal person or a woman?
I would actually love to see this scene played with a female gravedigger and a male Hamlet who might, condescendingly, ask his next question, as a concession to the lady gravedigger. Or even better – what if the gravedigger were non-binary and Hamlet’s questions are not just part of a vaudeville routine but also an attempt to engage with the gender of the person before him.