Any moment in the play "Macbeth" when the audience is privy to more pertinent information than one or more characters onstage is an instance of dramatic irony. An example is when King Duncan exhibits a positive outlook upon arriving at Inverness, where the audience already knows he will be murdered. Shakespeare Online posits that this play is exceptional for its pervasive use of dramatic irony.
Another example of dramatic irony with King Duncan is when he expresses trust for Macbeth in act one, scene four, having no idea that Macbeth is going to kill him. This same scenario elicits dramatic irony from the character of Lady Macbeth when, two scenes later, she affects a genteel and formalized language in welcoming the king, after the audience has just heard her ruthlessly plotting his death with Macbeth in the scene prior.
In this way, Shakespeare throws his characters' flaws into sharper relief. The errors the characters make along the way stand out all the more when the audience is aware of their impending doom. Knowing what is coming when the characters do not creates feelings of suspense, sympathy, fear, disbelief or even anger in the audience. This heightens the emotional experience of the play and creates dramatic irony.