How are historical circumstances reflected in Hamlet?
In 1600 (the approximate date of Hamlet), queen Elizabeth was sixty seven and had no direct heirs. England had been subjected to wars and rebellions over the succession to the throne for the preceding two centuries.
Queen Elizabeth had no heirs and Prince Hamlet had no way to succeed in ruling his father's kingdom. His father was dead and he wanted revenge.
Hamlet chose a convoluted way to get what he wanted: revenge. In England at the time of queen Elizabeth, the heir to the throne was in dispute.
Not marrying and having a child of her own meant that the succession to the crown was unsettled for Queen Elizabeth. Elizabeth did not like to talk about the succession and tried to have talk of it suppressed, but people were anxious about what would happen to the country when she died. However, having a child of her own may not have been an end to all problems. In the eyes of Catholics, Elizabeth was illegitimate and had no right to the throne. To them, Mary, Queen of Scots was the rightful Queen of England. Plots were made to make Mary queen and these would have been formed regardless of whether Elizabeth had a child or not. This is perhaps especially so when Mary was Elizabeth's prisoner following her disastrous reign in Scotland.
Forced to flee her own country, having abdicated her throne in favour of her son, she landed in England, seeking Elizabeth's help in restoring her to her kingdom. She was immediately imprisoned. This was as much to protect her as to minimize the danger she posed to Elizabeth. Mary was kept a prisoner for almost twenty years. In that time, Elizabeth refused to hear about executing her cousin, but Mary's complicity in the Babington plot of 1586 made the execution, in the eyes of many, unavoidable. It was a traumatic time for Elizabeth, and for a while it seemed that she would not have the strength to go ahead with the execution, but she did, and Mary was executed at Fotheringay Castle on 8 February 1587.
In the end, they were in similar tragic situations.