Dramatic irony occurs when the reader or audience of a work is aware of information that at least one character is not. Consider Disney's The Lion King. Viewers know that Scar is responsible for Mufasa's death, but Simba does not. Watching Simba's reaction to Scar's actions builds tension.
The same applies to Romeo and Juliet. There are several times in the play when the audience is aware of information that the characters are not, and it both builds tension and deepens the suspense that drives the plot forward.
The most tense example, of course, is when Romeo rushes to Juliet's tomb, believing that she has died. The audience is aware of the potion that only makes her appear dead, and that truly keeps the audience on the edge of its collective seat when Romeo delivers these words:
Ah, dear Juliet,
Why art thou yet so fair? Shall I believe
That unsubstantial death is amorous,
And that the lean abhorrèd monster keeps
Thee here in dark to be his paramour?
For fear of that, I still will stay with thee,
And never from this palace of dim night
Depart again. (V.iii.110–117)
It's difficult to avoid screaming at Romeo here, "She's still beautiful because she's still alive!"—that's the effect Shakespeare wanted. It's a tragedy, after all.
Another example is that Juliet's parents are preparing for her wedding, and they think she's on board. In actuality, she's preparing to run off to join Romeo in exile. That provides not only tension but also a brief chuckle here and there in moments like this:
This is as ’t should be.—Let me see the county.
Ay, marry, go, I say, and fetch him hither.—
Now, afore God, this reverend holy friar!
Our whole city is much bound to him. (IV.ii.32–35)
If her father had any clue that this friar had already married his daughter to a Montague, thanks isn't exactly what he would offer the good friar.
From the very prologue, the audience is aware of this:
A pair of star-crossed lovers take their life,
Whose misadventured piteous overthrows
Doth with their death bury their parents' strife. (Prologue.6–8)
It's clear from the first lines how this will all end—a couple will fall in love, commit suicide, and thus end their parents's grievances. When the audience watches Romeo first encounter Juliet or see the two proclaim love during the balcony scene, it creates more tension because everyone is aware that this isn't going to end well. All that remains is how it will all fall into place.
The dramatic irony in Romeo and Juliet helps the audience better connect with these characters and their struggles and create tension that is essential to plot development.