Ecclesiastes 12:9

And moreover, because the preacher was wise, he still taught the people knowledge; yea, he gave good heed, and sought out, and set in order many proverbs.

The preacher is Solomon in his later years, after his repentance, when he was again wise. He carried out this teaching in meekness and lowliness. He still taught the people knowledge, giving good heed and carefully seeking out and setting in order many proverbs.

This work was part of recording the lessons of his wasted years as warnings for later generations. Those warnings can benefit others even though his own people suffered the consequences of his mistakes.