According to E.R. Dodds in his essay "On Misunderstanding the Oedipus Rex," although Oedipus' fate was foretold, it was not decreed that he would know the truth. He was destined to kill his father and marry his mother, but the gods did not indicate that he would know what he had done. In fact, he has fulfilled the prophecy by the time the play begins despite his efforts to thwart his fate.
His own arrogance and pride are responsible for the tragedy he suffers. Because he feels so proud that he alone was able to solve the riddle of the sphinx and save Thebes, he is certain that only he can once again save the city, this time from the plague. He ruthlessly pursues the truth, determined to discover the identity of the murderer of King Laius when he learns that that the plague is the result of that man's presence in the city. Ironically, of course, he is unaware that the man he seeks is himself. Although Tiresias tries to dissuade him from this search, Oedipus persists, even accusing the old prophet and Creon of conspiring against him. Oedipus loses all reason and disregards everyone's advice, even Jocasta's, when she suspects the truth earlier than he does.
Nothing in the prophecy indicates that Oedipus will learn that he has killed his father and married his mother. The gods allow him some degree of free will, and unfortunately, he chooses to learn the awful truth.
You can read Dodds' essay by using the website below where a professor has provided a copy:
The issue of fate was the main reason that the play ended the way it did. Too many of the characters were doing their best to avoid fate, and that interfered with the normal process of life. It could only end in tragedy.
From the beginning, Jocasta and Laius sent their child away because a prophet said that Oedipus would grow up and kill his parents. To avoid this, Jocasta hand delivered her baby to a servant who placed him in the mountains. Here he was rescued by a loving couple who could not have children. They adopted him.
As Oedipus grew up, he found out from a prophet that he would grow up to kill his father and marry his mother. In order to once again avoid fate, he left his city. On his journey, he encountered Laius, killed him, made his way to Thebes to answer a riddle and took over Thebes. Thus, he married and fathered children with his original mother.
All of this could have been avoided had people not tried avoiding fate. Because they tried to escape their fate, only tragedy could occur.