When Queen Jocasta and King Laois had a baby, they found out from the oracle that when he grows up, he's going to kill his own father and marry his mother.
No! That's impossible!
That son of yours will kill his father and he will also marry your wife- the queen.
In fear of what may happen, the King and Queen sent their son to his death with the shepherd. However, the shepherd could not kill the child and accidentally came across to another shepherd that took the child to Corinth where he could have a chance to live his life.
The shepherd then gave Oedipus to another king and queen. They took care of him and raise him as their own. Oedipus was not aware of what happened when he was still a baby.