The story itself is told in a 3-part series of a play, of which "Oedipus the King" is the first part. Oedipus is born to King Laius and Queen Jocasta, but there are strange prophecies that predict the newborn will kill his father and marry his mother. So, in fear, they abandon the baby in the wilderness to die. A kind shepherd takes the infant Oedipus and brings him to another royal family in Corinth, and he is raised well there. But the prophecy follows him; Oedipus thinks that it is referring to his current household, so in fear of killing his adopted father and marrying his adopted mother, he flees. But on his journey he ends up killing Laius, not knowing it is his father. He then answers a riddle posed in the kingdom which wins him marriage to Jocasta, his mother. He does not know any of this at the time. Eventually, Jocasta figures it all out and kills herself. Oedipus discovers the truth also and puts out his eyes from shame, and the play ends with him devastated and banished from the kingdom.
The main idea is that you cannot escape fate; and by attempting to, you only help it to happen. I have provided a link to a more thorough summary and discussion below, and I hope this helps!
The title "Oedipus the King" is actually a very misleading translation of the Greek title of the play "Oedipus Tyrannos" by Sophocles. One key to understanding the main idea of the play is to analyze why this mistranslation matters.
A "king" is a hereditary ruler who gains legitimacy by succeeding his parents. A "tyrant" in Greek means an absolute ruler who is not a king but normally comes to power by a military coup or popular acclaim (the word "tyrant" didn't have the negative connotation it has for us today). Often "tyrants" were populists who rebelled against hereditary wealth and power.
At the start of the play, Oedipus is technically a tyrant, appointed by popular acclaim after saving the city from the Sphinx. He marries Jocasta, wife of the previous king Laius, attaching him to the hereditary source of legitimacy by marriage.
A plague has been visited upon the city of Thebes by the god Apollo. As Oedipus seeks to discover the source of the plague, he finds out that he was actually the son of Laius, a man he murdered accidentally at the crossroads before the start of the play, and Jocasta, who is now his wife. Horrified, he blinds himself and exiles himself from the city. Thus, ironically, at the end of the play, he ceases to be a tyrant and is shown to be a legitimate king at precisely the moment he renounces power.
Thus one of the more important ideas of the play concerns what constitutes legitimate power.