The verse in Kohelet (11:9) states: “Rejoice young man in your youth and let your heart cheer you up in your adolescence and walk in the path of your heart and in the sight of your eyes; but know that for all of these, G-d shall bring you into justice.” The Gemara (Shabbat 63b) states, “Rav Huna said, ‘These are the words of the Evil Inclination.’” This means that Rav Huna explains that the entire aforementioned verse in Kohelet is told to an individual by his Evil Inclination.
Nevertheless, this is somewhat difficult to understand, since the beginning of the verse “Rejoice young man in your youth and let your heart cheer you up in your adolescence and walk in the path of your heart and in the sight of your eyes”, seems like something the Evil Inclination would tell a person. However, the end of the verse, “But know that for all of these, G-d shall bring you into justice”, seems like something the Good Inclination would say, not the Evil Inclination!
Hagaon Harav Yaakov Krantz, the great Dubno Maggid, explains in his Kol Yaakov, a commentary on Megillat Kohelet, that the Evil Inclination seduces an individual in the beginning of his life to follow the hedonistic pursuits this world has to offer and to leave the Torah and Mitzvot. When the individual begins to mature and analyze the meaning of his life, especially when he realizes that his senior years are edging closer, he begins experiencing feelings of remorse for his actions and then begins wishing to repent and gather merits he can take along with him to the World to Come.
At this point, the Evil Inclination appears on the scene once again but takes the guise of the Good Inclination and he begins frightening the individual and showing him how great his punishment will be in the World to Come, as the verse states, “But know that for all of these, G-d shall bring you into justice”, meaning that he tells the individual, “See here how you have already wasted all your good days wantonly and the sins of your youth are innumerable; you will never have time to repent for and mend all of your wicked actions.”
Thus, the Evil Inclination then convinces the person that if he does not have any chance of achieving a share in the World to Come anyway, he may as well enjoy himself in this world.
Based on this, the Evil Inclination says the entire verse, as he starts off by saying “Rejoice young man in your youth” and then tells him, “Let your heart cheer you up in your adolescence” and finally, he convinces the individual to slack off in repenting since “For all of these, G-d shall bring you into justice” so it just makes sense to enjoy the rest of your days in this world at the very least.
This is what King Solomon warns us about in his Kohelet that even if the Evil Inclination tries to sway an individual in this way, do not believe him, for our Sages teach us (Talmud Yerushalmi, Chagiga, Chapter 2) that one may repent until the exit of his soul and the Gates of Repentance are always wide open for one to return to his Creator.