The story of the play originates in the legend of Hamlet (Amleth) as recounted in the twelfth-century Danish History, a Latin text by Saxo the Grammarian. This version was later adapted into French by Francois de Belleforest in 1570. In it, the unscrupulous Feng kills his brother Horwendil and marries his brother's wife Gerutha. Horwendil's and Gerutha's son Amleth, although still young, decides to avenge his father's murder. He acts the fool in order to avoid suspicion, a strategy which succeeds in making the others think him harmless. With his mother's active support, Amleth succeeds in killing Feng. He is then proclaimed King of Denmark. This story is on the whole more straightforward than Shakespeare’s adaptation. Shakespeare was likely aware of Saxo's version, along with another play performed in 1589 in which a ghost apparently calls out, "Hamlet, revenge!" The 1589 play is lost, leading to much scholarly speculation as to who might have authored it. Most scholars attribute it to Thomas Kyd, author of The Spanish Tragedy of 1587. The Spanish Tragedy shares many elements with Hamlet, such as a ghost seeking revenge, a secret crime, a play-within-a-play, a tortured hero who feigns madness, and a heroine who goes mad and commits suicide.
The Spanish Tragedy was one of the first and most popular Elizabethan "revenge tragedies," a genre that Hamlet both epitomizes and complicates. Revenge tragedies typically share a few plot points. In all of them, some grievous insult or wrong requires vengeance. Often in these plays the conventional means of retribution (the courts of law, generally speaking) are unavailable because of the power of the guilty person or persons, who is often noble if not royal. Revenge tragedies also emphasize the subjective struggle of the avenger, who often fights (or feigns) madness and generally wallows in the moral difficulties of his situation. Finally, revenge tragedies end up with a dramatic bloodbath in which the guilty party is horribly and often ritualistically killed. Hamlet is not Shakespeare's first revenge tragedy - that distinction belongs to Titus Andronicus, a Marlovian horror-show containing all of the elements just mentioned. But Hamlet is generally considered the greatest revenge tragedy, if not the greatest tragedy, if not the greatest play, ever written.
The central reason for the play's eminence is the character of Hamlet. His brooding, erratic nature has been analyzed by many of the most famous thinkers and artists of the past four centuries. Johann Wolfgang von Goethe described him as a poet - a sensitive man who is too weak to deal with the political pressures of Denmark. Austrian psychoanalyst Sigmund Freud viewed Hamlet in terms of an “Oedipus complex,” an overwhelming sexual desire for his mother. This complex is usually associated with the wish to kill one’s father and sleep with one’s mother. Freud points out that Hamlet's uncle has usurped his father's rightful place, and therefore has replaced his father as the man who must die. However, Freud is careful to note that Hamlet represents modern man precisely because he does not kill Claudius in order to sleep with his mother, but rather kills him to revenge his father’s death. Political interpretations of Hamlet also abound, in which Hamlet stands for the spirit of political resistance, or represents a challenge to a corrupt regime. Stephen Greenblatt, the editor of the Norton Edition of Shakespeare, views these interpretive attempts of Hamlet as mirrors for the interpretation within the play itself - many of the characters who have to deal with Hamlet, including Polonius, Claudius, and Rosencrantz and Guildenstern, also develop theories to explain his behavior, none of which really succeeds in doing so. Indeed, nothing sure can be said about Hamlet except that it has been a perennial occasion for brilliant minds to explore some of the unanswerable questions of human existence.