Another interpretation: "And he begot a son" — for from him the world would be rebuilt: "this one shall comfort us." Was Lamech then a prophet? Rabbi Shimon ben Yehotzadak said: there was a tradition in Adam's hands. When it was said to him (Genesis 3:17), "Cursed is the ground because of you," he said before Him: Master of the world, how long? He said to him: Until a man is born already circumcised from his mother's womb. And when [Noah] was born circumcised, [Lamech] said, "This one shall comfort us." Our Rabbis taught: when a wicked man comes into the world, evil comes into the world, as it is said, "When the wicked comes, contempt also comes" (Proverbs 18:3). When a wicked man perishes from the world, good comes into the world, as it is said (Proverbs 11:10), "And when the wicked perish, there is glad song." When a righteous man departs from the world, evil comes into the world, as it is said, "The righteous one perishes, and no man takes it to heart," and so forth. When a righteous man comes into the world, good comes into the world, as it is said, "This one shall comfort us from our deeds."
Lamech Foresees the Comforter and the Righteous Bring Good
Yalkut Shimoni on Torah 42:4
דָּבָר אַחֵר, וַיּוֹלֶד בֵּן, שֶמִמֶנּוּ נִבְנָה הָעוֹלָם זֶה יְנַחֲמֵנוּ. וְכִי נָבִיא הָיָה לֶמֶךְ, אָמַר רַבִּי שִׁמְעוֹן בֶּן יְהוֹצָדָק, מָסֹרֶת הָיָה לְאָדָם, כְּשֶׁנֶּאֱמַר לוֹ (בראשית ג, יז) "אֲרוּרָה הָאֲדָמָה בַּעֲבוּרֶךָ" אָמַר לְפָנָיו, רִבּוֹנוֹ שֶׁל עוֹלָם עַד מָתַי, אָמַר לוֹ עַד שֶׁיִּוָּלֵד אָדָם מָהוּל מִמְּעֵי אִמּוֹ, וְכֵיוָן שֶׁנּוֹלַד אָמַר זֶה יְנַחֲמֵנוּ. תָּנוּ רַבָּנָן, רָשָׁע בָּא לָעוֹלָם רָעָה בָּאָה לָעוֹלָם שֶׁנֶּאֱמַר "בְּבוֹא רָשָׁע בָּא גַם בּוּז". אָבַד רָשָׁע מִן הָעוֹלָם, טוֹבָה בָּאָה לָעוֹלָם, שֶׁנֶּאֱמַר (שם יא, י) "וּבַאֲבֹד רְשָׁעִים רִנָּה". צַדִּיק נִפְטָר מִן הָעוֹלָם רָעָה בָּאָה לָעוֹלָם, שֶׁנֶּאֱמַר "הַצַּדִיק אָבָד וְאֵין אִישׁ שָׂם עַל לֵב" וְגוֹ'. צַדִּיק בָּא לָעוֹלָם, טוֹבָה בָּאָה לָעוֹלָם, שֶׁנֶּאֱמַר זֶה יְנַחֲמֵנוּ מִמַּעֲשֵׂנוּ.