Oedipus Rex is a play set in the ancient Greek city of Thebes. As with many Greek tragedies, the events actually portrayed on stage are caused by things that happened in the past, some of which would have been known to the audience from mythology and some of which are gradually revealed over the course of the play.
Oedipus's parents were King Laius and Queen Jocasta. Laius, during a period of civil strife in Thebes was raised in the court of Pelops (part of another of the cursed dynasties who are the subject of many tragedies), but ended up raping and abducting Pelops' son. The gods cursed Laius to bearing a son who would kill him and marry Jocasta.
At the beginning of the play, Oedipus is king of Thebes, and married to Jocasta. A great plague has befallen Thebes, brought about by a divine curse. Creon, who is the brother of Jocasta, goes to the oracle of Apollo to find out the cause of the curse and returns to tell Oedipus that to lift the curse, Oedipus must find the murderer of Laius. The blind seer Teiresias first urges Oedipus not to delve into the issue and then, in an argument, states that Oedipus himself is to blame for the plague.
The audience then finds out that Laius was murdered by robbers at a place where three roads met in Phocis. Oedipus then reveals that although he was raised as the son of Polybus of Corinth and Merope, he later heard rumors that he was adopted. He also remembers the incident at the crossroads where he did kill an old man. As Oedipus delves more deeply into his own past, he finds out that in fact he was a foundling, adopted by the childless rulers of Corinth. Next, the audience discovers that when Jocasta bore a son, Laius, to avoid the prophecy of his being killed by his own son, asked a servant to take the baby and expose it on a hillside. Instead, the servant gave the baby to a shepherd who in turn gave it to the Corinthian royal family. That baby was Oedipus.
Jocasta, horrified by this information, hangs herself. Oedipus blinds himself by stabbing his eyes with pins from Jocasta's dress and abdicates. Creon takes over as king, agrees to look after Oedipus's daughters, and leads Oedipus offstage.