Another way of stating this question would be to ask, did the characters who end up dead at the end of the play deserve to die? In the broadest theological sense, Shakespeare would answer yes: in a Christian worldview, we are all born sinners, and for that reason, all of...
Another way of stating this question would be to ask, did the characters who end up dead at the end of the play deserve to die? In the broadest theological sense, Shakespeare would answer yes: in a Christian worldview, we are all born sinners, and for that reason, all of us pay the price by eventually dying. This is a question Hamlet explores in the play, both when he talks about humans fearing the afterlife (and so not committing suicide) and when he looks at Yorick's skull and notes that death is great leveler: every human, young or old, will die.
But, to be discerning, how do we specifically evaluate the crimes of the central characters? We can certainly say that Claudius deserved to die: he cold-bloodedly murdered to get the throne and felt no remorse. He also tried several times to have Hamlet murdered.
Hamlet killed Polonius, but that was an unpremeditated error. He also arranged for the deaths of Rosencrantz and Guildenstern, but we could (perhaps) call that self-defense. He showed no remorse over any of these deaths, which is more troubling. He made some mistakes but probably didn't quite deserve to die, as he was driven to desperation. But this is arguable: you need to think about it.
Gertrude seems to have married a man she didn't love simply to secure her own safety and stay on the throne. Is that the best reason to marry? No. Does it deserve death? No.
Laertes comes home ready to kill Hamlet to avenge his father's death and willingly participates in the plot to use a poisoned rapier against Hamlet. However, he repents of his hotheadedness. He, too, probably doesn't deserve to die. Given a little time, he would most likely have come to his senses.
"Justice" went a bit overboard at the end of the play, and therefore, the ending wasn't entirely just. But all the deaths satisfy the requirements of the revenge drama, and they do clean house and allow for a new beginning.