This question has been asked and answered many times here on eNotes. Here is a comprehensive link for you: http://www.enotes.com/oedipus-rex/q-and-a/tags/dramatic+irony
In Sophocles's Oedipus Rex, the title character is a classic example of Aristotle's tragic hero. Oedipus, who unknowingly kills his biological father and marries his biological mother, is widely recognized as one of the most unfortunate victims of fate in all of literature.
The play opens with Oedipus making a vow to find the killer of Laius in order to free the city of Thebes from punishment by the gods. A genuinely good man who cares deeply about his people, Oedipus vows to stop at nothing to find and punish Laius's murdered. The entire speech, along with many other lines/situations from the rest of the play, can be labeled as dramatic irony since the audience knows something (that Oedipus is Laius's biological son and murderer) that Oedipus doesn't know:
Now, since I am ruler and hold this kingdom
that he held before—holding also the bed
and wife we have both sown; and children
of the same mother would have been born to us,
had his line not been ill-fated—since chance(270)
has driven me into that one’s powers,
therefore I shall fight for him in this matter,
as if for my own father, and I shall try
everything, seeking to find the one who
committed the murder, for Labdacus’ son,(275)
son of Polydorus, and before him
Cadmus and Agenor, kings of old.
As the plot of the play unfolds Oedipus finally comes to understand who he is and what he has done. And keeping his word, he banishes himself from Thebes for his actions.
In the tragic story of Oedipus, the author uses irony as a literary technique. It is ironic that Oedipus runs away form home to keep the prophecy from coming to past when in fact he runs directly into his destiny.
By leaving Corinth, Oedipus felt sure that he could keep the prophecy that he would kill his father and marry his mother from coming to past. Along the way where three roads meet, he is nearly run over by a chariot. Ironically, the man inside the chariot is Oedipus' biological father. In a rage, Oedipus kills King Laius, not realizing the man happens to be his father.
Another twist of irony is when Oedipus demands that the murderer of King Laius be sought for and killed or exiled. Ironically, Oedipus is serving his own death sentence, not knowing at this point that he in fact is his father's murderer. Determined to drive the pollution from the land, ironically, Oedipus is driving himself out of the land, for he is the pollution.