The body of oral-traditional myth on which Sophocles based his play Oedipus Rex includes the backstory to the play, one that ancient Greek readers would have known.
King Laius, while guest of Pelops, seduced in some way the son of Pelops. Pelops cursed Laius with the fate that Laius would be killed by his own son. Jocasta mentions this:
Here is the proof in brief. An oracle
Once came to Laius ... declaring he was doomed
To perish by the hand of his own son,
The plot evolves from Laius trying to avoid the curse by having Oedipus killed as a baby, but, of course, fate cannot be avoided that easily and eventually the curse (willed by the gods) is fullfulled. The sufferings of Oedipus are ended in another part of the tradition, retold in Sophocles Oedipus at Colonus.
The underlying message in all of Sophocles' plays, is that people must have proper reverence for the gods. Oedipus, in seeking to evade the prophesies of the gods, ended up fulfilling the prophesies. Excessive pride (hubris) in his own abilities and in his own reasoning, led to his downfall. Thus the inherent message in Oedipus Rex is to submit to the will of the gods; otherwise your hubris will play a part in bringing you down.