"Better a poor but wise youth than an old but foolish king who no longer knows how to take warning." NIV translation
You can almost feel the sorrow as Solomon looks back at his younger days and the wisdom that he was granted by God. He contrasts that to where he is now which was that he had disobeyed God and married women he was told that he could not.
"The youth may have come from prison to kingship, or he may have been born in poverty within his kingdom." NIV translation
Solomon recounts the fact that God chooses the king and often He does not choose the ones we would expect.
His father David was the least of his brothers and yet God chose him to be the king.
"I saw that all who lived and walked under the sun followed the youth, the king's successor. There was no end to all the people who were before them. But those who came later were not pleased with the successor. This too is meaningless, a chasing after the wind." NIV translation
Because of his disobedience, God had told Solomon that his kingdom would be divided and that is what he speaks of here. The king had tried to build up the kingdom to pass on to his son and yet it was destined to be divided. The same type of thing happens today in that many people work all the time and hope to build up a fortune to leave to their kids. Often the business or money that is left to them is wasted or thrown away. In the end, their hard work to build it up was no more than chasing after the wind.