After Avraham defeated the four kings in battle, the king of Sodom made a request: "Give me the people and take all the spoils for yourself" (Bereishis 14, 21). To which Avraham replied that he swears not to take any of the bounty lest someone claim that it was he who made Avraham wealthy. The Ramban explains that the impetus for Avraham's swearing was to keep his yetzer hara in check. He cites a Sifrei which states that we find such conduct by all righteous men: they swear in order to prevent their yetzer hara from causing them to sin.
Rav Wolbe (Shiurei Chumash) comments that it is only the righteous who conduct themselves in such a manner. When they are concerned that their desires might get the best of them, they swear not to fall prey to their yetzer hara, thereby effectively erecting a fence between them and the sin, for they certainly will not renege on a promise. However, most of us are not concerned with such apprehensions. Therefore, we are often smug and do not take the necessary precautions to avoid likely or imminent aveiros. The Torah teaches us that this is not the proper way. The righteous do not trust themselves, and when an opportunity for sin presents itself they immediately incapacitate their yetzer hara by swearing not to falter.