For the youth has come from the prison to the kingship, though he was born poor in his own kingdom.
Solomon was himself a king, and therefore may be allowed to speak more freely than another concerning the vanity of kingly state and dignity, which he shows here to be an uncertain thing; he had before said so (Pro 27:24, The crown doth not endure to every generation), and his son found it so. Nothing is more slippery than the highest post of honour without wisdom and the people's love.
Commenting on Ecclesiastes 4:13-16
For out of prison he cometh to reign,.... That is, this is sometimes the case of a poor and wise child; he rises out of a low, mean, abject, obscure state and condition, to the highest dignity; from a prison house, or a place where servants are, to sit among princes, and even to have the supreme authority: so Joseph, to whose case Solomon is...
out of prison--Solomon uses this phrase of a supposed case; for example, Joseph raised from a dungeon to be lord of Egypt. His words are at the same time so framed by the Holy Ghost that they answer virtually to Jeroboam, who fled to escape a "prison" and death from Solomon, to Shishak of Egypt (Kg1 11:40).