What was the political situation when Shakespeare wrote Hamlet? Did the political situation have any relationship with the plot of Hamlet?
In Hamlet, the state of Denmark is politically similar to but not exactly a mirror of England at the time of the play. More accurately, the external political situation in Denmark is analogous to the internal predicament of Hamlet.
In Denmark (external): "It is bitter cold"
In Hamlet (internal): "I am sick at heart"
Denmark: "Denmark's a prison"
Hamlet: "O God, I could be bounded in a nutshell."
Denmark: "something's rotten in the state of Denmark."
Hamlet: "O that this too too sullied flesh would melt..."
In terms of politics, both countries were police states. The walls had ears, and there were spies everywhere, from within and without. England and Denmark kept their friends close and their enemies closer. Just as Young Fortinbras is surrounding Denmark, so too were the Spanish waiting for England to implode.
Both countries practiced Machiavellian politics: the courts were based on duplicity, power, fear. Security lay in the balance. Polonius is the most Machiavellian character in the play; he constantly eavesdrops and meddles in others' affairs.