Dickens uses dramatic irony early in the novel as a way of highlighting young David Copperfield’s innocence and gullibility. For example, when David travels alone to Salem House in Chapter 5, a waiter takes advantage of his good nature and ready willingness to believe everything he is told:
I replied that he would much oblige me by drinking [my ale], if he thought he could do it safely, but by no means otherwise. When he did throw his head back, and take it off quick, I had a horrible fear, I confess, of seeing him meet the fate of the lamented Mr Topsawyer, and fall lifeless on the carpet. But it didn’t hurt him. On the contrary, I thought he seemed the fresher for it.
The waiter starts by easily convincing David that someone came through the inn recently and dropped dead from drinking the ale. Only those who are used to it, the waiter claims, can drink it safely. He offers to dispose of the ale for David and moves on to giving reasons why he should eat every other part of the big meal that has been reserved for David.
By the time the waiter drinks the ale and is fine, the reader understands what David does not: this man is manipulating him to get a nice meal. The dramatic irony builds throughout the scene, as it becomes more and more obvious what the waiter is doing. This building dramatic irony makes David both the butt of the joke and also the object of the reader’s sympathy. He is either innocent or polite to the point of being pathetic. Anyone with sense and self-respect in David's place would insist on eating the meal himself, but poor young David clearly has neither of these. The scene is thus important to the arc of the novel as a Bildungsroman. It demonstrates how much growing up David will need to do, even at his young age, in order to survive in the world, let alone thrive.
In Chapter 45, Annie explains why she is glad she did not marry Jack Maldon, and her words stick with David for a reason he can't work out. There is dramatic irony in this moment because to both the reader and to the adult narrator, it is obvious why Annie's words resonate with him:
I pondered on those words, even while I was studiously attending to what followed, as if they had some particular interest, or some strange application that I could not divine. ‘There can be no disparity in marriage like unsuitability of mind and purpose’—‘no disparity in marriage like unsuitability of mind and purpose.’
It has been clear to the reader for some time that David and Dora are unsuited to one another, both in mind and purpose. David wanted a wife who could be his equal partner and who was talented at managing a household. This does not describe Dora, who struggles with housework and has recently asked David to refer to her as his "child-wife." David is all too happy to use this condescending name because he truly does not recognize other strengths Dora might bring to the partnership to equal his own. Dora, meanwhile, wanted a husband who would protect her from any and all upsets and who would provide her with riches. This does not describe David, who works for a modest income and regularly upsets Dora. David was attracted to Dora because she was like a charming doll he could play with, but that was never the "purpose" of marriage to him.
Despite their clear mismatch, David has not yet done enough self-reflection to realize his error in selecting Dora as his wife. This moment, when Annie's words stick with him, reveals that he is almost ready to admit it to himself. Still, he keeps himself in the dark a little longer by failing to apply Annie's wisdom to his own life. Doing so would require that he accept that he has behaved somewhat like Mr. Murdstone in his marriage to Dora. Additionally, it might require noticing the person in his life who actually would make a suitable wife: Agnes. If suitability of mind and purpose make for a good marriage, David has overlooked the person he ought to have married in favor of one he ought not to have married.