Rav Hirsch states (on Noach 6:6) that this is not a matter or "regretting" a decision (as a man would regret a mistake), but that the expression of Man's free will caused an external series of events. An example that Rav Hirsch uses is Shaul Hamelech. That is, we cannot understand Hashem and we are attempting to explain what it is we see or that happens in human terms. Thus we anthropomorphize the description of Hashem by using human terms like regret. However, we have to be careful not to take such terms literally.
Of course Hashem had appointed Shaul to be King, but when Shaul
rendered himself unworthy to continue reigning, Shaul's alteration in
behavior caused Hashem to alter His decision.
Rav Hirsch explains that these expressions are necessary to teach the concept of free will and that Hashem does not punish without careful examination of Man's deeds.
The two anthropomorphic expressions here save the two essential
conceptions: the freedom, the free-will of Hashem and that of Man.
Not for nothing does it say, "When Hashem saw etc". The wickedness of
Man was not a matter of necessity. Hashem had to see it before He knew
it. This expression gives us the guarantee of human free-will. And the
fate that overtook mankind was not the result of physical causes which
followed set laws, it was preceded by an examination by Hashem and His
decision; the decision itself pained the Decider. All this presupposes
the personality and free-will of Hashem and keeps this clear in our
minds.
As Rashi says
And the Lord regretted that He had made: Heb. וַיִנָּחֶם. It was a consolation to Him that He had created him [man] of the earthly beings, for had he been one of the heavenly beings, he would have caused them to rebel. [This appears in Genesis Rabbah (27:40).
and He became grieved: [I.e.,] man [became grieved],
in His heart: [the heart] of the Omnipresent. It entered the thought of God to cause him [man] grief. This is the translation of Onkelos [i.e., Onkelos supports the view that וַיִּתְעַצֵּב refers to man]. Another explanation of וַיִּנָּחֶם: The thought of the Omnipresent turned from the standard of clemency to the standard of justice. It entered His thoughts to reconsider what to do with man, whom He had made upon the earth. And similarly, every expression of נִחוּם in Scripture is an expression of reconsidering what to do. [For example] (Num. 23:19): “Nor the son of man that He should change His mind (וְיִתְנֶחָם)”; (Deut. 32:36): “And concerning His servants He will change His mind (יִתְנֶחָם)”; (Exod. 32:14): “And the Lord changed His intent concerning the evil (וַיִּנָּחֶם)”; (I Sam. 15:11): “I regret (נִחַמְתִּי) that I made [Saul] king.” These are all an expression of having second thoughts.
and He became grieved: Heb. וַיִּתְעַצֵּב, He mourned over the destruction of His handiwork [i.e., according to this second view, וַיִּתְעַצֵּב refers to God], like (II Sam. 19:3): “The king is saddened (נֶעֱצַב) over his son.” This I wrote to refute the heretics: A gentile asked Rabbi Joshua ben Korchah, “Do you not admit that the Holy One, blessed be He, foresees the future?” He [Rabbi Joshua] replied to him, “Yes.” He retorted, “But it is written: and He became grieved in His heart!” He [Rabbi Joshua] replied, “Was a son ever born to you?” “Yes,” he [the gentile] replied. “And what did you do?” he [Rabbi Joshua] asked. He replied, “I rejoiced and made everyone rejoice.” “But did you not know that he was destined to die?” he asked. He [the gentile] replied, “At the time of joy, joy; at the time of mourning, mourning.” He [Rabbi Joshua] said to him, “So is it with the work of the Holy One, blessed be He; even though it was revealed before Him that they would ultimately sin, and He would destroy them, He did not refrain from creating them, for the sake of the righteous men who were destined to arise from them.” - [from Gen. Rabbah 27:4]