John Gill's Exposition of the Whole Bible
Ecclesiastes 4:14
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 thought to have respect, and which is mentioned in the Midrash; who was but a young man, and poor and friendless, but wise; and was even laid in prison, though innocent and guiltless, from whence he was fetched, and became the second man in the kingdom of Egypt; so David, the youngest of Jesse's sons, was taken from the sheepfold, and set upon the throne of Israel: though Gussetius e interprets this of the old and foolish king, who comes out of the house or family, הסודים, of degenerate persons, as he translates the word, with a degenerate genius to rule; the allusion being to a degenerate vine; which sense agrees with Ecclesiastes 4:13, and with what follows;
whereas also [he that is] born in his kingdom becometh poor; who is born of royal parents, born to a kingdom; is by birth heir to one, has it by inheritance, and has long possessed it; and yet, by his own misconduct, or by the rebellion of his subjects, he is dethroned and banished; or by a foreign power is taken and carried captive, and reduced to the utmost poverty, as Zedekiah, Nebuchadnezzar, and others: or if born poor, so Gussetius; with a poor genius, not capable of ruling, and so loses his kingdom, and comes to poverty. Or it may be rendered, "although in his kingdom he is born poor" f; that is, though the poor and wise child is born poor in the kingdom of the old and foolish king; yet, out of this low estate, in which he is by birth, he comes and enjoys the kingdom in his room to such a strange turn of affairs are the highest honours subject: or, "for in his kingdom he is born poor" g; even the person that is born heir to a crown is born a poor man; he comes as naked out of his mother's womb as the poorest man does; the conditions of both are equal as to birth; and therefore it need not seem strange that one out of prison should come to a kingdom. But the first sense seems best.
e Ebr. Comment. p. 553. f כי גם "quamvis etiam", Gejerus. g "Nam etiam", Tigurine version, Cocceius; "quia etiam", Pagninus, Montanus, Schmidt, Rambachius, so Aben Ezra.