Vatishachet ha'aretz lifnei ha'Elokim - The earth was corrupt before G-d

This is reference to the idolatry practiced by man.  The Torah alluded to the fact that the sins of mankind included both trespasses gainst G-d as well as trespasses against society.  They corrupted religion and they corrupted the basics of procreation.  These latter sins also included indiscriminate robbery amonst the people.  The Torah refers to this by writing vatimale ha'aretz - "and the earth was filled with violent crime"  and the repetition ki-male'ah ha'aretz - "the earth is filled with violent crime" (v13). 

The Torah reports G-d's decision to bring on the deluge in connection with the report of the violence, therefore it is clear that this sin weighed most heaveily and that the decree to destroy mankind was not sealed until G-d had reviewed the indiscriminate violence on earth (Sanhedrin 108).

Support for this view is found in two verse of Sefer Yeshayahu.  Yeshayahu 54:14 states, "You shall keep away from oppression [do not engage in it] and you shall have no fear, and from ruin and it shall not come near you."  Yeshayahu had said previously (v9), "that this is like the deluge to Me..."  In other words, Yeshayahu [in the name of G-d] warns the people that the deluge had been due to the violence and oppression practiced by people against each other. 

The reason why this was the most critical sin was that it is a trespass against common sense.  If there were no G-d at all, mankind would have to legislate laws controlling violence as otherwise civilization would collapse of its own.  A society which did not even observe such a code of laws could not expect to endure.

Just the very occurrence of the deluge is proof positive that the universe was a creation and that a Creator presides over it and watches it; it proves that the same Creator punishes those who are guilty and saves the ones who deserve to be saved such as Noach and his family.  It proves further that G-d's supervision is not limited to the celestial spheres but that it extends to our "lower" world also.  Just as Adam was the ancestor of all mankind after him, so Noach became the ancestor of all mankind after the deluge. 

Just as Adam had three sons, Kayin, Hevel, and Shet, so Noach had three sons, Shem, Cham, and Yafet.  Just as two of Adam's sons were his mainstay whereas the third one was cursed, so you find that one of Noach's sons was cursed.  Just as Adam's third son was the one who became the link to posterity, so Noach's third son is the true link to posterity as only the descendants of Shem are the ones who will qualify for resurrection (according to Rashi - Shem was indeed the third, i.e. the youngest son of Noach). (R. Bachya)