A foil in literature is a character who contrasts the protagonist (typically) in order to draw attention to specific qualities about that protagonist. For example, the foil's morality throws the protagonist's lack of morals into even greater relief by contrast. In Oedipus Rex, Creon serves as Oedipus's foil because he is reasonable while Oedipus is rash. For example, when Oedipus accuses Creon of plotting with the prophet Teiresias to steal Oedipus's crown, Creon calmly and rationally points out all the reasons he would not want to be the king. Oedipus, on the other hand, behaves more like a petulant child who insists on his way of seeing things despite all the evidence to the contrary.
Creon exercises forethought and circumspection while Oedipus blusters and makes errors due to his inability (or unwillingness) to think ahead. Early in the play, when Creon returns from the oracle with news about the fate of Thebes, he wishes to move his conversation with Oedipus inside the palace, away from the eyes of the whole city. Oedipus, however, refuses. He cannot see how discretion in this instance could be beneficial. This leads him to curse Laius's killer publicly, a stance from which he cannot then back down later.
This is a great question. In the most important ways, Creon is the opposite of Oedipus. For this reason, the qualities that Oedipus has in excess are highlighted.
Oedipus is a strong leader who is hot-tempered. As we read the play, he will stop at no cost and he is confident that he can solve any problem. He calls down curses on the murderer and he will do all within his power to solve any problem.
Creon, on the other hand, is even-tempered. Creon is able to remain calm in the face of troubles and think things through. In this way, we can see that Oedipus is characterized by stubbornness and hubris - pride.
When we look at it from this angle, we can see that Oedipus' hubris not only drives the play, but also has a big role in his downfall. Had he been a more even-tempered person, he would not have killed his father and married his mother.