In Parshat Ki Tavo, Moshe Rabbeinu describes the curses which God will inflict on Bnai Yisrael if they do not act in accordance with the Torah. The Parsha implies that the Bet Hamikdash will be destroyed because of Bnai Yisrael's wrongdoing. Many view these curses as a threat by Hashem, that He will punish the Jewish people for sinning. However, there are those who suggest that the curses are not meant as a condemnation from God. Rather, the Torah is warning us of a natural process of events that will take place if we turn against Hashem. A punishment is not necessarily the way Hashem pays us back for sinning, but may be the natural result caused by the sin itself.
This is similar to a doctor telling his patient, "If you eat certain foods you will become sick." It is most obvious that the doctor is not cursing the patient to become sick. Rather, he is trying to prevent the patient from becoming ill, by outlining what will happen if the patient disobeys the his directions.
Likewise, the Torah warns us (28:58-59) "If you do not observe the words of the Torah... to fear the glorious and fearful name, to fear the Lord your God..." The point is if we do not observe the Torah, we will have to face the consequences.
With this explanation in mind, it is clear why we must do Teshuva, repentance. The sin is a cause that leads to a punishment. Thus, we are able to nullify our sins through true Teshuva. If we do Teshuva for our sins before our punishment takes effect, we can divert the natural process of cause and effect, leading to the punishment, taking a different route away from that punishment.
If there is a cliff at the end of the road, one would hope there would be a sign warning travellers of the dangers ahead. The Torah gives us these warnings to keep us away from the spiritual cliff. Teshuva gives us the opportunity to stay away from that cliff.