Ge 6:9 This is the genealogy of Noah. Noah was a just man, perfect in his generations. Noah walked with God.
10 And Noah begot three sons: Shem, Ham, and Japheth.
11 The earth also was corrupt before God, and the earth was filled with violence.
12 So God looked upon the earth, and indeed it was corrupt; for all flesh had corrupted their way on the earth.
13 And God said to Noah, "The end of all flesh has come before Me, for the earth is filled with violence through them; and behold, I will destroy them with the earth.
Moses in writing about Noah here in this section intended to teach Israel three things:
First, God is the judge of all the earth. No other deity has this authority. He alone is the judge of all humanity.
Second, God judges sin but preserves those who walk with Him.
Third, the earth can be defiled by human sin.
If Israel wishes to remain in the land of milk and honey, Israel must walk with God. Otherwise, God will judge and punish Israel for defiling the land.