Dramatic irony arises from a circumstance in which an audience member knows something about a character or situation in a play that a character doesn't know.
A person unfamiliar with the ancient Greek Oedipus myth as dramatized in Sophocles's Oedipus Rex would experience far fewer examples of dramatic irony in the play than a person who is already familiar with the myths surrounding Oedipus.
An audience member watching a performance of Oedipus Rex at the Festival of Dionysus in 429 BC was already familiar with the Oedipus myth. They heard the myth repeated time and time again from a young age, and they knew the myth of Oedipus and the characters involved in the story as well as a modern audience member knows any fairy tale or superhero adventure story.
The playgoer in 429 BC knew before the play begins that Oedipus killed his father, Laius, and married his mother, Jocasta. They knew that Oedipus saved Thebes from the Sphinx. They knew the names of Oedipus and Jocasta's four children. They may have even known what Oedipus had for breakfast on the fateful day in Sophocles's play that Oedipus discovers that he did, in fact, kill his father and marry his mother.
An audience member attending Oedipus Rex in 429 BC wasn't interested in the story, which they already knew. They would have wanted to know how the playwright crafts the story, the changes and twists and turns, if any, that the playwright adds to the story, and the playwright's skill as a poet.
In Poetics, Aristotle praises Oedipus Rex as a perfect example of a Greek tragedy and cites Oedipus as a perfect example of a tragic hero. Aristotle refers to only one event in the play—when the messenger comes to Thebes to tell Oedipus that his adoptive father, Polybus, has died—and assumes that his reader knows the rest of the story.
For the audience member familiar with the Oedipus myth, almost the entirely of the play was an example of dramatic irony. They already knew what's going to happen. What they wanted to know was how the playwright made it happen.
For an audience member unfamiliar with the Oedipus myth, Oedipus Rex is a murder mystery: who killed Laius? The viewer watches the plot of the story unfold and picks up clues to the murder along the way. There's very little dramatic irony because the viewer has no idea what's going to happen.
In time, the viewer learns, along with Oedipus, that Oedipus killed Laius, just like Teiresias said he did. They also learn the whole backstory about Oedipus being fated by the gods to kill his father and marry his mother, how as a newborn baby Oedipus was taken to the mountains to die, how Oedipus came to be adopted by King Polybus and Queen Merope in Corinth, how Oedipus saved Thebes from the Sphynx, and all of the many other elements of the Oedipus myth that Sophocles managed to integrated seamlessly into Oedipus Rex.
Accordingly, in exploring and discussing elements of dramatic irony in Oedipus Rex or any other play based on well-known myths and legends, it's important to consider the point of view of the audience member and clearly distinguish between foreknowledge and hindsight.