How can New Historicism be applied to Macbeth and Hamlet?
To answer your question, it is important to review what New Historicism is. The New World Encyclopedia defines the concept:
New Historicism is an approach to literary criticism and literary theory based on the premise that a literary work should be considered a product of the time, place, and historical circumstances of its composition rather than as an isolated work of art or text.
In other words, this approach tries to understand a piece of literature based not only by what is within it, but also on the context of the historical time period in which it was written.
With this in mind, New Historicism can be applied to both of Shakespeare's plays, Macbeth and Hamlet.
Shakespeare wrote his plays for an Elizabethan/Jacobean audience. This era was known as the English Renaissance, influenced by the Italian Renaissance that began a hundred years prior. After the political upheavals that had dealt such heavy blows to her country prior to her ascension to the throne, Elizabeth I welcomed and supported the rebirth of the arts. When she died, James I continued the practice.
Attending the theater was, surprisingly, something that appealed to all socioeconomic levels of society. The "cheap" seats, ironically, were the closest seats. What we perceive as the "nose bleed" section today was reserved for royalty, to rise above the more common folk. (It was so popular that when the plague broke out, the theater was the first place to be closed.)
In terms of New Historicism, it would be important to know the historical context of the play's audience. The audience knew its history and would recognize historical figures portrayed. Things we don't find funny today would have been openly comic then.
A playwright who was a wise man would make sure to direct some part of his play to compliment the current monarch. In Macbeth, the man who takes over when the tyrant Macbeth is killed is Malcolm, who is presented as a truly virtuous man and was related to James I (Shakespeare's king), who was also James VI of Scotland (the setting of the play).
In both Macbeth and Hamlet, it is important to note that Elizabethans believed whole-heartedly in the supernatural. Witches and apparitions in Macbeth, and the Ghost in Hamlet would have captivated the audience. Whereas we might think these aspects of the play silly, Shakespeare's audiences would have watched while holding a collective breath. (Witch-hunts were real!)
Also during this time period, the practice of hospitality was a very serious affair. If someone was in your home, whether a friend or archenemy, his safety was guaranteed. It was a question of honor. So in Macbeth, not only was Macbeth killing his king, but also his guest.
Elizabethans believed that kings and queens were chosen by God. Therefore, it was a mortal sin to kill a king. Macbeth does just that, upsetting the balance of the universe which is restored with his death and the rightful king on the throne. Hamlet's struggle as to whether to kill Claudius is based on this and the supernatural. If the Ghost is an evil apparition, he could lose his soul to eternal damnation by killing Claudius, if his uncle did not kill Old Hamlet. But if Claudius did, Hamlet is safe.
With these things in mind, in order to comprehend the implications and relevance of these plays, one needs to be aware of the historical context of when each was written.