1 Kings 2:16

And now I ask one petition of thee, deny me not. And she said unto him, Say on.

The verse stands in the account of David's final days and Solomon's accession and reign, within the history of Israel's undivided kingdom. It lies in the first eleven chapters of 1 Kings that give the life of Solomon, in the sequence from Saul, succeeded by David and Solomon, to the kingdom's final overthrow.
Its immediate setting is after David's death, when Solomon carries out the measures his father had charged him to take to secure the throne. Adonijah frames his address to Bath-sheba as asking one single petition and asking her not to refuse it before he reveals what it is. The request is part of a shrewd plot to gain the kingdom, since possessing the king's concubine would strengthen his claim among the people.

The verse falls within Adonijah's attempt to gain the throne after Solomon's coronation, an attempt that was defeated and ended in his own death. Adonijah and Joab are later put to death, and Shimei is also executed after failing to keep the conditions set for him. Adonijah's attempt threatened David and Solomon and was another fulfillment of Nathan's words that the sword would not depart from David's house. Adonijah's petition to Bathsheba is the opening of the rebellion that led to his death, and that rebellion and death are part of the retribution that came back on David through the rest of his life for his wicked conduct toward Uriah. This proves that wrongdoing brings calamity and sorrow back on the wrongdoer in the very kind sown and that sin is repaid in its own kind.

The surrounding chapter also shows God bringing upon Shimei the just reward of his wickedness. In David's dark hour, when Absalom had stolen the hearts of the people by fair words and David had to flee from Jerusalem to save his life with only a few followers while the mass was with Absalom, Shimei came out and cursed David and cast stones and dust upon him and his men. He accused him of being a wicked, bloody man, and delighted in naming his calamities over as evidence that God was not with him. David bore it meekly, God soon worked for him, and in the end punished Shimei justly.