I’ve seen this cross my feed a few times now, and it’s certainly a poetic piece of rhetoric. But you know what? I think it’s almost completely wrong.
Allow me to explain. To begin with, punishments absolutely can “undo the crime” for a great many crimes and circumstances. When a thief is punished by being made to restore what he stole (or its equivalent monetary value) to whomever he stole from, the crime has been in a very real sense ‘undone’. Sure, the time in which the thing was stolen can’t be erased, but the compensation extracted from the thief can take that into account. And once the thing is returned, situations can (in many cases) simply return to the way they were before it was stolen.
This is obviously impossible, of course, in the case of murder (for mere mortals, anyway; I will refrain from considering divine intervention here). But even then, there are things that can be done: the murderer can be deprived of whatever ill-gotten gains the murder profited them, and they can be prevented from committing future murders, to name two. Whether or not they no longer deserve life themselves, they certainly don’t deserve to simply continue with their life as before. Even if the punishment can’t completely “undo the crime”, there’s still a big difference between letting it stand entirely unchallenged, and undoing what parts of it can be undone.
Continuing backwards: personally enacting revenge by killing the murderer may also be unjust, but not because it accomplishes nothing. Revenge can’t “undo the past”, but the only way it can be said to “re-enact the past” is in the mere materialistic sense of one person killing another person. The materialistic sense is an incomplete one here precisely because the context and motivations for the act are significantly different.
And contrary to the assertion that “there is nothing you can ever do about the past”, there most certainly is something you can do about it: in depriving a murderer of their ill-gotten gains (whether by legitimate or illegitimate means), a very significant part of the past is, in fact, “undone”. Furthermore, in bringing the murderer to justice, you are preventing them from perpetuating their crimes any longer. How is that not a “purposive action directed towards the future”? It certainly seems like one to me. So these don’t seem to be correct things to say, either.
Now, on to the specifics. Setting aside the question of whether Hamlet’s “preconceptions about the nature of life” were really shattered (as opposed to merely his preconceptions or estimations about his mother and uncle), questions about “what could be done” would seem to have an obvious answer. Hamlet, on a personal level as the son of the victim, and on an official level as a member of the Danish royal family and heir to the throne, has no small amount of legitimate interest in seeing the murderer, who is also the reigning king, brought to justice. As a royal, surely there would have been multiple avenues for him to pursue in bringing his uncle to justice by legitimate means, rather than resorting to killing him personally.
The problem isn’t that Hamlet desires to see something done, the problem is that he chooses to take it entirely upon himself to do it, and lets his lust for revenge overbalance the need for justice. Once he became certain of Claudius’ guilt, he could’ve confronted him privately, or publicly accused him before the court. He could’ve tried to find witnesses to testify that his father’s body didn’t have a snake bite on it at all, so that it wasn’t merely Claudius’ words against his. Really, there are any number of paths Hamlet could’ve taken here which would’ve been entirely legitimate.
The characterizations of the ghost’s motivations as “purely selfish” and the task as doing “no possible good” thus also look false. I fail to see where the ghost is requiring that Hamlet pursue revenge as a private and personal matter, instead of publicly and legally. Hamlet at least contradicts the ghost’s request insofar as he certainly does “contrive against” his mother. How, then, can the ghost be said to be “at fault” in any sense?
The tragedy of Hamlet isn’t that “no action can be of any use” and Hamlet acts anyway, the tragedy is that Hamlet, in his fury, chooses one of the worst possible courses of action he could possibly have chosen, and persists in it long after it should’ve become blatantly obvious how unwise a course of action it was.