Foreshadowing in Macbeth
These words are filled with dreadful irony and foreshadowing. Considering how Macbeth has already imagined a floating dagger prior to killing Duncan and his current agitated state, the likelihood that one or both of them will mentally suffer as a consequence of this action is a distinct possibility.
Knocking is a motif throughout Macbeth. After Macbeth and his wife complete their hideous murder, they hear a knock within that causes them to immediately fear and begins their slow descent into guilty madness. The Porter imagines Hell's Gate and unwittingly invokes two symbols. First, Macbeth's castle begins to resemble hell as he has committed a hideous crime. Second, the Porter reminds the audience that bad deeds, such as murder and suicide, are met with punishment in hell. This foreshadows not only Macbeth and Lady Macbeth's coming end, but the promise of punishment in the afterlife for their ambition. It is unclear whether or not this line was the basis for the modern Knock, Knock joke.
Shakespeare uses these signs and warnings to foreshadow that more unpleasantness will happen. The eclipse and the story of the owl and falcon to show how nature has become unbalanced as a result of Duncan's murder.
Lady Macbeth uses this speech to calm Macbeth's guilty conscious. However, her flippant response to Macbeth's worries, essentially there's no changing what has happened so forget about it, comes back to haunt her when she begins to feel pangs of guilt. Her "what's done is done" later transforms into "what's done cannot be undone," as Lady Macbeth becomes overrun with guilt.
Even though the last vision upset him, Macbeth still trusts the rest of the information the three witches gave him. Therefore, by making this statement, Macbeth doesn't realize that he is actually damning himself, foreshadowing what happens to him as a result of his belief in the witches' prophesies.