In Genesis 6:5-7, it says the Lord regretted making human beings. If God is omniscient, why would this be the case?
Here is the passage to which you refer:
When the LORD saw how great the wickedness of human beings was on earth, and how every desire that their heart conceived was always nothing but evil, the LORD regretted making human beings on the earth, and his heart was grieved. So the LORD said: I will wipe out from the earth the human beings I have created, and not only the human beings, but also the animals and the crawling things and the birds of the air, for I regret that I made them.
It is important to remember that the Scriptures are meant to help us understand God. When we are young in our spiritual development, things are explained to us differently than when we are more mature in our spiritual development (1 Cor. 3:1-2). Similarly, Scripture over time revealed more and more as the Jewish people matured in their relationship with God (Heb. 1:1). And so the Scriptural authors occasionally use anthropomorphism to help the reader understand their larger point.
In this passage the key phrase is “his heart was grieved.” In ancient Jewish culture the heart is not necessarily a place of emotion and feeling, rather it is a place of thinking and judgment (Wis. 9:3). This expression is telling us that God is rendering a negative judgment upon humanity. It is not a cruel and cold judgment but a true and honest judgment that creates a tension with God’s love for his creation. The “regret” that God is described as experiencing is the author’s way of explaining that God does not act arbitrarily or with malice.
The author of this passage was not rendering a philosophical treatise on the nature of the divine essence. The author was explaining to the readers that God does not want to destroy his creation but in justice he must pass judgment (Ezek. 18:23, Lam. 3:33-40, 2 Pet. 3:9).