2 Samuel 19:8

Then the king arose, and sat in the gate. And they told unto all the people, saying, Behold, the king doth sit in the gate. And all the people came before the king: for Israel had fled every man to his tent.

This belongs to the history of David's reign concerning Absalom's rebellion and death, including David's lament over Absalom, his fear and flight, and his return to Jerusalem. It depicts David resuming public leadership after Absalom's defeat, as he arises and sits in the gate and all the people come before him after Israel had fled every man to his tent or home. The surrounding account involves the difficulties David encountered, the sad family troubles growing out of his many or multiplying wives and sons he could not control, his troubles with Joab, and his numbering of the people. The history records the judgments and retribution that followed David's great transgression and wicked conduct toward Uriah, coming back upon him in kind and fulfilling Nathan's prophetic denunciation.

That retribution continued through all the rest of David's life, principally within his own family in Amnon and Tamar and in the rebellion and unnatural crimes of Absalom. The verse thus teaches that what a man sows, that he shall reap: wrongdoing brings calamity and sorrow upon the wrongdoer, and it can never pay to do wrong. The detailed faithfulness of the account marks it as inspired and shows that God does not hide the sins of even the greatest kings.