Genesis 6:5-8
Yahweh saw that the wickedness of man was great in the earth, and that every imagination of the thoughts of his heart was only evil continually. Yahweh was sorry that he had made man on the earth, and it grieved him in his heart. Yahweh said, “I will destroy man whom I have created from the surface of the ground; man, along with animals, creeping things, and birds of the sky; for I am sorry that I have made them.” But Noah found favor in Yahweh’s eyes.
This passage is puzzling to a human mind. How could a God who knows everything ever feel sorry that He made anything? After all, He is God and He does exactly what He wants to. What we must remember when thinking about this passage is that God had planned this and everything that was to happen after it from the beginning of the world. We know this because the Bible also tells us that God knew that Jesus was to die for our sins before the creation of the world, so somehow, we would have to exist until that time.
1 Peter 1:18-20 :
knowing that you were redeemed, not with corruptible things, with silver or gold, from the useless way of life handed down from your fathers, but with precious blood,
as of a faultless and pure lamb, the blood of Christ; who was foreknown indeed before the foundation of the world, but was revealed at the end of times for your sake,
You see, God knew that this was going to happen, and since God knows everything, He also knew that by making us that He was going to be sorry. God planned His own regret. He did this because He wanted to show us how much He loved us and how much He hates sin. We are about to witness both of these things as we read about the flood.
Notice that mankind in general stopped thinking good and right thoughts but instead, “every imagination of the thoughts of his heart was only evil continually.” God still longs for us to have right hearts and minds today. As Christians, we have right hearts and minds and can live right lives to if we allow the Holy Spirit to help us.