In parashat Bechukotai, G"d tells us what will happen if we follow the commandments, and what will happen if we don't. In the end, there is a built in forgiveness for our sins - Gd telling us that the covenant will not be abrogated, at least on G"d's part. But the forgiveness only comes after all the suffering we have endured because of our failure to keep the holy commandments.
Leviticus 26:39 "The few of you who survive in your enemies' lands will [realize that] your survival is threatened as a result of your non-observance. [These few] will also [realize] that their survival has been threatened because of the non-observance of their fathers."