Let us remember that dramatic irony is defined as one character or several characters and the audience possessing knowledge that another character or group of characters does not have. What is key to note in this scene is that it is juxtaposed or placed next to Act I scene 3, which is when Macbeth receives the prophecy from the witches that has such a big impact on his life. In this prior scene, Macbeth shows himself to be seriously considering how he might become King as the prophecy suggests. It is then highly ironic that he plays the role of loyal subject and that Duncan is so naively trustful of him. Note the intense irony when Duncan comments about the previous Thane of Cawdor who has just been executed:
There's no art
To find the mind's construction in the face:
He was a gentleman on whom I built
An absolute trust--
However, having realised this valuable life lesson, Duncan goes on to repeat exactly the same mistake. He does not have the "art" to see what is going on in Macbeth's mind and is taken in by the act of his loyalty, once again building an "absolute trust" in someone only to be betrayed, and this time killed, by them. Thus, the dramatic irony serves to emphasise the good nature of Duncan and his naive character. He has not learnt his lesson from the treachery of the former Thane of Cawdor and is once again too quick to trust too quickly, with devastating circumstances.