Free Will and a Broken Heart
Man's desires are just evil all day long and Hashem regretted creating man.

(ה) וַיַּרְא יי כִּי רַבָּה רָעַת הָאָדָם בָּאָרֶץ וְכָל־יֵצֶר מַחְשְׁבֹת לִבּוֹ רַק רַע כָּל־הַיּֽוֹם׃ (ו) וַיִּנָּחֶם יי כִּֽי־עָשָׂה אֶת־הָֽאָדָם בָּאָרֶץ וַיִּתְעַצֵּב אֶל־לִבּֽוֹ׃ (ז) וַיֹּאמֶר יי אֶמְחֶה אֶת־הָאָדָם אֲשֶׁר־בָּרָאתִי מֵעַל פְּנֵי הָֽאֲדָמָה מֵֽאָדָם עַד־בְּהֵמָה עַד־רֶמֶשׂ וְעַד־עוֹף הַשָּׁמָיִם כִּי נִחַמְתִּי כִּי עֲשִׂיתִם׃

(5) Hashem saw how great was man's wickedness on earth, and how every plan devised in his heart was nothing but evil all the time. (6) And Hashem regretted that He had made man on earth, and Hashem's heart was saddened. (7) Hashem said, “I will blot out from the earth the men whom I created—men together with beasts, creeping things, and birds of the sky; for I regret that I made them.”

Sforno on Genesis 6:5 (Ovadia ben Jacob Sforno, Italy, 1475-1550)
כי רבה רעת האדם, how great was man's wickedness on earth - a reference to the past;
וכל יצר לב האדם, every plan devised by his mind was nothing but evil all the time - a reference to the future when it would not improve.
וירא ה', כיון שהגיע הקץ שנהן להם מאה ועשרים שנה ראה כי לא הטיבו מעשיהם אבל הריעו אותם וכל יום היה קשה מתברו, זהו שאמר "רק רע כל היום". ופירוש וכל יצר, משני יצרים שיש בלבו של אדם אחד טוב ואחד רע, כלו היה לרע ולא היה טוב בהם. ונקראת תאות מחשבת הלב, יצר, לפי שהלב יוצר ופועל בלבו הענינים הן לטוב והן לרע להוציאם לידי מעשה. וטעם מה שהאריך האל להם ק"כ שנה אם ישובו, והוא היה יודע שלא ישובו, עשה כן כדי שילמד אדם ממדותיו ויאריך אפו לחוטא ולא ינקום ממנו מיד אע"פ שהיכולת בידו אולי יתחרט בו וישוב. והנה האל ברא עולמו להיות טוב או כולו או רובו, ואם כולו רע לא יוכל לעמוד כי לא יבחר האל כי אם בטוב; והנה ראה דור המבול כולו רע בזנות וחמס שמפסידין סדר העולם והיו מעשיהם כנגד מעשיו, ואמר להשחית רת העולם השפל ולהשאיר ממנו הטוב שנמצא בו והיה שמץ מנהו כדי לקיימו לעתיד, והשאיר בו נח שמצא אותו טוב וכן בניו עם נשותיהן כדי לקיים זרע ולמך אביו כבר מת חמש שנים לפני המבול, ומתושלח שלמו שנותיו בבא המבול ומת, כי חמש שנים חי אחר למך בנו, הנה לא נשאר צדיק בעולם אלא נח ובניו:

God saw that the time God had allocated to the people to improve their ways had elapsed, but nothing had changed. Nothing but evil all the time - רק רע כל היום, the words every plan (וכל יצר) refer to both man’s urges, the urge to do good (yetzer hatov), and the urge to do evil (yetzer hara). The urge to do good had succumbed to the evil urge, completely...

When God created the human race, God wanted it to be good completely, or at least predominantly. If humankind would turn to be completely evil it could not endure, seeing that God had chosen the good. When God saw that the generation preceding the deluge was thoroughly evil, especially in their interpersonal relations, their use of violence as a legitimate tool to gain their ends, their deeds threatened to undermine the foundations upon which God had built the universe. God, therefore, decided to destroy all those who were evil and to save only the few good ones, so that these survivors could form the nucleus of a better human race after the deluge.

וירא ה'. אמנם ה' ראה שגם מה שהמעיט מספר שנותיהם לא הועיל. כי רעת האדם רבה והולכת. וכל יצר. כי החוטא מצד התאוה יש תקוה שיחדל מלחטוא כשלא יתאוה או לעת זקנתו ורשעים כאלה מלאים חרטה, לא כן החוטא בעצת השכל שזה יוסיף תמיד ברשע, וז"ש שראה כי גם ציורי מחשבותיו רק רע ולא יעלה בנפשו ציור טוב מוסרי רק ציורי התאוות והמדות הרעות, וזה מתמיד כל היום:

Hashem saw that even reducing their life spans to 120 years did not cause them to repent. This was because their sins were the result of ideology as well as appetite.

כי רבה רעת האדם אין להרהר ולומר הואיל והכל גלוי לפניו איך בראו לחטוא, הרי אין יראת שמים בידי שמים כדכתיב ועתה ישראל מה ה׳‎ אלקיך שואל מעמך וגו׳‎ וכתיב מי יתן והיה לבבם זה להם וגו׳‎ וכתיב ראה נתתי לפניך היום את החיים ואת הטוב את המות ואת הרע.

One could posit that seeing that God has foreknowledge of all that humans will do, creating them had been an exercise in futility to start with; therefore, why had God bothered? The answer is that everything is under the control of heaven except man’s decision to either live in awe of the Creator or to defy the Creator. Seeing that God had decided to create a creature equipped with free will, God had simultaneously abrogated the right to interfere.

(יב) וְעַתָּה֙ יִשְׂרָאֵ֔ל מָ֚ה יי אֱלֹקֶ֔יךָ שֹׁאֵ֖ל מֵעִמָּ֑ךְ כִּ֣י אִם־לְ֠יִרְאָה אֶת־יי אֱלֹקֶ֜יךָ לָלֶ֤כֶת בְּכָל־דְּרָכָיו֙ וּלְאַהֲבָ֣ה אֹת֔וֹ וְלַֽעֲבֹד֙ אֶת־יי אֱלֹקֶ֔יךָ בְּכָל־לְבָבְךָ֖ וּבְכָל־נַפְשֶֽׁךָ׃

And now, O Israel, what does Hashem your God ask of you? Only this: to revere Hashem your God, to walk only in God's paths, to love God, and to serve Hashem your God with all your heart and soul.

(טו) רְאֵ֨ה נָתַ֤תִּי לְפָנֶ֙יךָ֙ הַיּ֔וֹם אֶת־הַֽחַיִּ֖ים וְאֶת־הַטּ֑וֹב וְאֶת־הַמָּ֖וֶת וְאֶת־הָרָֽע׃

See, I set before you this day life and prosperity, death and adversity.

(ג) ויתעצב אל לבו. נִתְאַבֵּל עַל אָבְדַן מַעֲשֵׂה יָדָיו, כְּמוֹ נֶעֱצַב הַמֶּלֶךְ עַל בְּנוֹ (שם ב' י"ט), וְזוֹ כָתַבְתִּי לִתְשׁוּבַת הַמִּינִים גּוֹי אֶחָד שֶׁשָּׁאַל אֶת רַבִּי יְהוֹשֻׁעַ בֶּן קָרְחָה, אָמַר לוֹ אֵין אַתֶּם מוֹדִים שֶׁהַקָּבָּ"ה רוֹאֶה אֶת הַנּוֹלָד? אָמַר לוֹ הֵן, אָמַר לוֹ וְהָא כְתִיב וַיִּתְעַצֵּב אֶל לִבּוֹ? אָמַר לוֹ נוֹלַד לְךָ בֵּן זָכָר מִיָּמֶיךָ? אָמַר לוֹ הֵן, אָמַר לוֹ וּמֶה עָשִׂיתָ? אָמַר לוֹ שָׂמַחְתִּי וְשִׂמַּחְתִּי אֶת הַכֹּל, אָמַר לוֹ וְלֹא הָיִיתָ יוֹדֵעַ שֶׁסּוֹפוֹ לָמוּת? אָמַר לוֹ בִּשְׁעַת חֶדְוָתָא חֶדְוָתָא בִּשְׁעַת אֶבְלָא אֶבְלָא, אָמַר לוֹ כָּךְ מַעֲשֵׂה הַקָּבָּ"ה, אַף עַל פִּי שֶׁגָּלוּי לְפָנָיו שֶׁסּוֹפָן לַחֲטוֹא וּלְאָבְדָן לֹא נִמְנַע מִלְּבָרְאָן בִּשְׁבִיל הַצַּדִּיקִים הָעֲתִידִים לַעֲמֹד מֵהֶם:

ויתעצב אל לבו And it grieved him on his heart — He mourned at the failure of His handiwork. Similarly ‘The king grieved (נעצב) for his son”.

The following extract from the Midrash Rabbah I am writing in order that you may know how to refute the arguments of certain heretics: A gentile once asked Rabbi Yehoshua ben Korcha, saying to him, “Do you not admit that Hashem, knows what is to happen in the future?” He replied, “Yes.” The gentile retorted, “But is it not written ‘and He was grieved in His heart’?” He answered: “Have you ever had a son born to you?” The reply was “Yes.” He asked (the gentile): “And what did you do?” He replied: “I rejoiced and I made others rejoice also.” The Rabbi asked him: “But did you not know that he must die?” The gentile replied: “At the time of joy, let there be joy, at the time of mourning let there be mourning”.

The Rabbi said: “Such, too, is the way of Hashem: although it was clear to Him that in the end men would sin and would be destroyed, He did not refrain from creating them for the sake of the righteous men who were to issue from them”,

וינחם ה', מה שאמר וינחם, דברה תורה בלשון בני אדם, כי על דרך האמת לא אדם הוא להנחם כי אין שנוי חפץ בו יתברך ויתעלה.

'וינחם ה, the expression, וינחם, “He was sorry, He regretted,” has been chosen by the Torah in order for human beings to have at least an inkling of what God’s feelings were when He faced destroying His handiwork. Clearly, such emotions as “regret” are not part of God’s vocabulary. We have it on the authority Samuel I 15 29 that human feelings such as regret, frustration, are not feelings which can be attributed To Him.

וְגַם֙ נֵ֣צַח יִשְׂרָאֵ֔ל לֹ֥א יְשַׁקֵּ֖ר וְלֹ֣א יִנָּחֵ֑ם כִּ֣י לֹ֥א אָדָ֛ם ה֖וּא לְהִנָּחֵֽם׃
And also the Eternal One of Yisra᾽el will not lie nor change his mind: for he is not a man, that he should change his mind.

(ד) וַיִּנָּחֶם יי כִּי עָשָׂה אֶת הָאָדָם בָּאָרֶץ (בראשית ו, ו), רַבִּי יְהוּדָה וְרַבִּי נְחֶמְיָה, רַבִּי יְהוּדָה אָמַר תַּוְהוּת הָיְתָה לְפָנַי שֶׁבָּרָאתִי אוֹתוֹ מִלְּמַטָּה, שֶׁאִלּוּ בָּרָאתִי אוֹתוֹ מִלְּמַעְלָה לֹא הָיָה מוֹרֵד בִּי. רַבִּי נְחֶמְיָה אָמַר מִתְנַחֵם אֲנִי שֶׁבָּרָאתִי אוֹתוֹ מִלְּמַטָּה שֶׁאִלּוּ בָּרָאתִי אוֹתוֹ מִלְּמַעְלָה כְּשֵׁם שֶׁהִמְרִיד בִּי אֶת הַתַּחְתּוֹנִים, כָּךְ הָיָה מַמְרִיד בִּי אֶת הָעֶלְיוֹנִים. אָמַר רַבִּי אַיְבוּ תְּוָהוּת הָיְתָה לְפָנַי שֶׁבָּרָאתִי בּוֹ יֵצֶר הָרָע, שֶׁאִלּוּלֵי לֹא בָּרָאתִי בּוֹ יֵצֶר הָרָע לֹא הָיָה מוֹרֵד בִּי. אָמַר רַבִּי לֵוִי מִתְנַחֵם אֲנִי שֶׁעָשִׂיתִי אוֹתוֹ וְנִתַּן בָּאָרֶץ. (בראשית ו, ו): וַיִּתְעַצֵּב אֶל לִבּוֹ, אָמַר רַבִּי בֶּרֶכְיָה, מָשָׁל לְשַׂר שֶׁבָּנָה פָּלָטִין עַל יְדֵי אַדְרִיכַל, רָאָה אוֹתָהּ וְלֹא עָרְבָה לוֹ, עַל מִי יֵשׁ לוֹ לְהִתְכָּעֵס לֹא עַל אַדְרִיכַל, כָּךְ וַיִּתְעַצֵּב אֶל לִבּוֹ. אָמַר רַבִּי אָסֵי מָשָׁל לְשַׂר שֶׁעָשָׂה סְחוֹרָה עַל יְדֵי סַרְסוּר וְהִפְסִיד, עַל מִי יֵשׁ לוֹ לְהִתְרָעֵם לֹא עַל הַסַּרְסוּר, כָּךְ וַיִּתְעַצֵּב אֶל לִבּוֹ. אֶפִּיקוֹרֶס אֶחָד שָׁאַל אֶת רַבִּי יְהוֹשֻׁעַ בֶּן קָרְחָה, אָמַר לוֹ אֵין אַתֶּם אוֹמְרִים שֶׁהַקָּדוֹשׁ בָּרוּךְ הוּא רוֹאֶה אֶת הַנּוֹלָד, אָמַר לוֹ הֵן. וְהָא כְתִיב וַיִּתְעַצֵּב אֶל לִבּוֹ. אָמַר לוֹ נוֹלַד לְךָ בֶּן זָכָר מִיָּמֶיךָ, אָמַר לוֹ הֵן, אָמַר לוֹ מֶה עָשִׂיתָ, אָמַר לוֹ שָׂמַחְתִּי וְשִׂמַּחְתִּי אֶת הַכֹּל, אָמַר לוֹ וְלֹא הָיִיתָ יוֹדֵעַ שֶׁסּוֹפוֹ לָמוּת, אָמַר לוֹ בִּשְׁעַת חֶדְוָתָא חֶדְוָתָא, בִּשְׁעַת אֶבְלָה אֶבְלָה. אָמַר לוֹ כָּךְ מַעֲשֶׂה לִפְנֵי הַקָּדוֹשׁ בָּרוּךְ הוּא, דְּאָמַר רַבִּי יְהוֹשֻׁעַ בֶּן לֵוִי שִׁבְעָה יָמִים נִתְאַבֵּל הַקָּדוֹשׁ בָּרוּךְ הוּא עַל עוֹלָמוֹ קֹדֶם שֶׁלֹא יָבוֹא מַבּוּל לָעוֹלָם, מַאי טַעְמֵיהּ וַיִּתְעַצֵּב אֶל לִבּוֹ, וְאֵין עֲצִיבָה אֶלָא אֲבֵלוּת, הֵיךְ מָה דְאַתְּ אָמַר (שמואל ב יט, ג): נֶעֱצַב הַמֶּלֶךְ עַל בְּנוֹ.

Rabbi Yehuda says, "[God said] that I regret that I created man below [on earth] since if I had created him above [in heaven] he would not have rebelled against Me."

Rabbi Neḥemia says, "[God said] that I am consoled that I created man below [on earth] since if I had created him above [in heaven], then just as he incited the lower worlds against Me, so too he would incite the upper worlds against Me."

Rabbi Aivu says "[God said] that I regret that I created the evil inclination, since if I had not created it, he would not have rebelled against Me."

Rabbi Levi says "[God said] that I am consoled that I made man and placed him on the earth [where he eventually dies]."

(יד) וַיִּנָּ֖חֶם יי עַל־הָ֣רָעָ֔ה אֲשֶׁ֥ר דִּבֶּ֖ר לַעֲשׂ֥וֹת לְעַמּֽוֹ׃ {פ}

(14) And Hashem renounced the punishment planned for God’s people.

God regrets, God is comforted. God makes mistakes.