What do we learn from "Hayisi Melech Al Yisrael bi'Yrushalayim"?
Rashi citing Sanhedrin 20b: At first (before he married Nochriyos), Shlomo was king (even) over higher beings (angels and Ruchos) - "va'Yeshev Shlomo Al Kisei Hashem." Later, he was king (only) over people "Hu Rodeh Al Kol Ever ha'Nahar mi'Tifsach v'Ad Azah". Later (because he did not repent), he was king only over Yisrael - "Hayisi Melech Al Yisrael." Later, he was king only over Yerushalayim - "Divrei Koheles? Melech bi'Yrushalayim." Later, he was only king over his bed - "Hinei Mitaso sheli'Shlomo?" In the end (refer to 1:12:1:2), he was only king over his staff - "v'Zeh Hayah Chelki mi'Kol Amali." I was king, but now I am not.
Gitin 68b: Shlomo had captured the king of the demons, to ask him where is a special worm needed to build the Mikdash. After he released him, he cast Shlomo him 400 Parsa'os (about 1600 kilometers). He was left with only his staff [or cloak or cup]. He went begging from door to door, saying "I, Koheles, was king over Yisrael."
Rav Sadya Gaon: I became king.
Ibn Ezra: Shlomo wrote Koheles in his old age, to tell future generations 'so I experimented during my life. I was able to experiment and try everything, for I was king.' It mentions Yisrael, for there were always Nevi'im and Chachamim among them, like Bnei Zerach 1 . Yerushalayim is a place proper to receive Chachmah. The world consists of seven regions (climates). Only the middle three are proper for Chachmah; the others are too hot or too cold.
Rashbam: Due to my grandeur, my heart was free [to investigate].
Ri Kara: Do not say that I said that all man's toil Tachas ha'Shamesh is Hevel, because I lacked them and did not try them, but had I gathered silver and gold and coveted things, I would not call them Hevel. I was king!
Seforno: I was able to gather Chachamim of the generation and explore the opinions, new and old.
Metzudas David: I was called Koheles, for I gathered the different opinions to refine and clarify the Emes. I was king over a wise nation, in Yerushalayim, the city of Chachmah. Therefore, my heart saw much Chachmah!
Metzudas Tziyon: Past tense (Hayisi) or future can be used for the present tense, e.g. "v'Halchu Vanav; ? Kachah Ya'aseh Iyov" (Iyov 1:4-5).
Magihah (in Toras Chayim): He holds that Ezrachi ("Eisan ha'Ezrachi", "Heiman ha'Ezrachi" - Melachim I, 5:11, Tehilim 89:1) is from Zerach ben Yehudah; the Aleph is extra.