"And I will establish My Brit with thee," (Bereshit, 17:21) that you shall be the sign of the Brit in the world. After that, "And thou shall come into the ark." For if he had not been a tzaddik (a guardian of the Brit) he could not have entered the ark, for only the tzaddik can unite with the ark. Therefore it is written, "And thou shall come into the ark," as has been explained.
Rabbi Elazar said, As long as men remain attached to this Brit and do not loosen their hold of it (do not blemish it with sexual sins,) there is no nation nor language in the world that can do them harm. Noach clung to Brit and guarded it, therefore the Holy One Blessed Be He safeguarded him. But all of his contemporaries did not guard the Brit, and because of this, the Holy One Blessed Be He removed them from the world. As has been stated, in exactly the same way that they sinned, they were blotted out from the world.