What is "Havel Havalim"?
Rav Sadya Gaon: It is the ultimate folly. Rashi - Havel has a Tzeirei under the Veis, for it is Samuch to Havalim. Ibn Ezra - normally, words like Eretz (with Segol under both letters) do not change when Samuch. This is an exception. A singular Samuch to a plural shows grandeur, like "Melech Melachim" (Yechezkel 26:7), or the opposite, e.g. "Eved Avadim" (Bereishis 9:25) and here.
Ri Kara: Many things last forever. What is totally Hevel? Man, like will be explained.
Seforno: Something new that does not have a good purpose is Hevel. What has a worse purpose is Havel Havalim, just like what is more Kadosh is Kodesh Kodoshim.
Metzudas David: Havel is a command. In this Sefer, Koheles tells people to Lehavhil (consider futile) and despise Havalim (follies).
Metzudas Tziyon: Hevel is something without substance. It is a borrowed expression, like Hevel Peh that Chazal said. It says "va'Yelechu Acharei ha'Hevel" (Melachim II, 17:15).
Why does it say "Amar Koheles" in the middle?
Rashbam: Sometimes [David] was anxious to mention "Hashem", so he inserted it, and returns to mention what he came to explain, e.g. "Lo Lanu Hashem Lo Lanu", "Nas'u Naharos Hashem Nas'u Naharos Kolam", "Ki Hine Oyvecha Hashem Ki Hine Oyvecha" (Tehilim 115:1, 99:3, 92:10). Also here, he inserts "Amar Koheles" and returns to explain. Koheles did not say these first two verses, rather, the one who arranged this Megilah 1 .
Rid: The verse should be re-arranged. It means, Amar Koheles, [worldly matters are] Havel Havalim.
Seforno: He said this after contemplating that some things are more Hevel than others.
Divrei Eliyahu: Chazal enacted seven Ma'amados due to the Havalim in this verse (refer to 1:2:5:1). Man's years are divided into three. Until 20 years is ascent, from 20 to 90 is Amidah (stationary), and after 90 is descent - 'Ben Tish'im Lashu'ach' (Avos 5:21), i.e. descent. Until 20 is ascent - there are higher things. At five he learns Mikra, at 10 Mishnah, at 13 he is obligated in Mitzvos, at 15 he learns Gemara, at 18 he marries (ibid.) After 20 are matters of Hevel - Lirdof (pursuing income), Ko'ach, Ziknah, Seivah, Gevurah. Even though there is Binah at 40, it is [sometimes] Hevel and Amidah, just like Ko'ach and Etzah 2 . If it is used for Torah and Mitzvos it is nice, like R. Yochanan told Reish Lakish 'your strength for Torah!' (Bava Metzi'a 84a) If he uses his strength for Aveirah, it is evil. Chachamim enacted seven Ma'amados corresponding to the seven decades of Amidah. Shmuel and Shlomo both lived 52 years; Shlomo became king at 12, and reigned 40 years. In his life he saw three decades of Amidah. Havel Havalim Amar Koheles - I saw three decades of Hevel - Havel Havalim ha'Kol Hevel, I know that also the remaining four decades of Amidah are Hevel.
Bava Basra 15a: Chizkiyah and his entourage wrote Koheles.
Also Etzah is not always Hevel - "u'Seshu'ah b'Rov Yo'etz" (Mishlei 11:14), it was a name of Chizkiyah (Yeshayah 9:5; Otzar Midrashim - it is a name of Mashi'ach), "u'Zecharyah Vno Yo'etz b'Sechel", "vi'Yehonason Dod David Yo'etz Ish Mevin" (Divrei ha'Yamim I, 26,14, 27:32). (PF)
Why is "Havel Havalim" repeated?
Ibn Ezra: The repetition teaches that it will always be so, like "Nas'u Naharos Hashem Nas'u Naharos Kolam", "Sabuni Gam Sevavuni" (Tehilim 99:3, 118:11).
Refer to 1:2:2:1.
Rid: Verses often repeat matters to strengthen them.
Seforno: Even if the artisan and form are esteemed, if the purpose is inferior, it is proper to be called Havel Havalim.
What do we learn from "ha'Kol Hevel"?
Rashi (12:8): This is everything created in six days of creation.
Ibn Ezra: Do not say that some worldly matters are Hevel, and others have a lasting root. All is Hevel!
Metzudas David: One should despise what has no proper purpose, but not something from which benefit will come.
What is the significance of the repetitions of "Hevel" in the verse?
Torah Temimah citing Bava Kama 100b: Corresponding to them, we stop no less than seven times while taking a Mes to burial. (Each "Havalim" counts as two.)
Rashi: The seven Havalim in the verse hint that everything formed in the seven days of creation is Hevel. R. Avigdor citing Koheles Zuta #1 - everything created will cease. "Shamayim ke'Ashan Nimlachu veha'Aretz ka'Beged Tivleh" (Yeshayah 51:6), "v'Namaku Kol Tzva ha'Shamayim" (i.e. the Raki'a) (ibid. 34:4), "v'Chol Esbam Ovish" (ibid. 42:15), "v'Chofrah ha'Levanah u'Voshah ha'Chamah" (ibid. 24:3), "Asof Of ha'Shamayim u'Dgei ha'Yom", "Asof Adam u'Vehemah" (Tzefanyah 1:3). Nothing was created on Shabbos; "Mechaleleha Mos Yumas" (Shemos 31:14), i.e. b'Mezid. For Shogeg, he brings a Korban and gets Kaparah 1 .
R. Avigdor citing Koheles Zuta #2: The seven Havalim correspond to the seven worlds that man sees from birth until death. His first year, he leaves the womb and everyone hugs and kisses him. His second and third years, he is like a pig. He puts in his mouth everything that he sees and finds. He makes himself repulsive in mud and excrement. When he is 10, he jumps like a kid. When he is 20, he is like a horse. He beautifies himself, and says 'who will bring to me a wife?' He marries, and he is like a donkey. He is saddled, and is blemished to (neglects) Torah. He bears children, and [then] he must pursue food for his household and children like a dog. He is blemished to Mitzvos. He gets old, and he is like a monkey. This refers to Resha'im. It says about Tzadikim "veha'Melech David Zaken 2 `" (Melachim I, 1:1).
R. Avigdor #3: They correspond to the seven days of Aveilus. In the end man dies, and people mourn over him.
R. Avigdor: When David saw this, he immediately said "Mizmor Shir l'Yom ha'Shabbos" (Tehilim 92:1. Shocher Tov (90, 92) says that Moshe or Adam composed it. Perhaps David himself was inspired to say it. - PF)
I.e. even when he is old, he is still considered a king.