The Torah states that after Hashem smelled the sweet smell of Noach's sacrifices, He said that He would never again curse the earth on account of man, because the inclination of man's heart is evil from his youth. Rather, as long as the earth remains, seed-time and harvest, cold and heat, summer and winter, and day and night shall not cease (בראשית ח:כ"א-כ"ב).
The Mishnah in Pirkei Avos (פרק ב' משנה ב') states: "It is good to combine the study of Torah with some worldly occupation, for the combination of the two keeps sin out of the mind of man." When one spends his time involved with work and study, he tends to forget about sin because it is idleness that often leads to sin, and an empty mind leaves room for evil thoughts to thrive. The Rambam thus explains (פרק כ"ב מהל' איסורי ביאה הלכה כ"א) that evil thoughts gain the upper hand only in a heart which is devoid of wisdom.
The Sefer מעיינה של תורה quotes from the Kometz HaMinchah that one of the problems with the people who lived in the generation of the Flood was that they lived in idleness. There was little need for physical labor. According to the Midrash, they needed to sow their fields only once to obtain crops for the next forty harvests. They also did not have Torah or wisdom with which to occupy their minds. They therefore became corrupt and rebelled against Hashem through their wicked actions. For this reason, Hashem concluded that because the wickedness of man was so great and because the thoughts of his heart were only evil all the time, He must wipe out the people whom He had created. (בראשית ו:ה-ז) For lack of work with which to occupy their time, they drifted into sin and had to be destroyed.
Following the Flood, however, Hashem accepted the sweet savor of Noach's sacrifice and regretted the evil He had decreed. He therefore said that He would not curse man again, nor would He seek to destroy man, because the evil impulses of man's heart are there from his youth; they are part of his nature. Instead, Hashem came up with another plan to control man's evil inclinations: He said that He would make man's life on earth difficult enough so that he will be forced to work hard in order to survive. He thus said, in the Posuk cited above, that as long as the earth endures, man shall be compelled to reap, to harvest and to toil in order to provide for his needs from season to season. Once he will be forced to work day and night with little free time, he will have little time for sin.
We may add that the alternative way to protect oneself from sin is by studying Torah. If one does have time free from work or responsibilities, one should use that time wisely to pursue Torah and wisdom, and not risk falling into the sinful activities which often result when one has too much leisure time. A good combination of work and study, as suggested by the above quoted Mishnah, will keep a person away from sin.