1 Kings 2:17

And he said, Speak, I pray thee, unto Solomon the king, (for he will not say thee nay,) that he give me Abishag the Shunammite to wife.

The verse stands in the first eleven chapters of 1 Kings, which present the life of Solomon, who succeeded David as king of Israel after Saul and before the kingdom was divided under Rehoboam.
Its setting is after David's death, as Solomon takes measures to secure his throne following Adonijah's attempt to exploit David's old age and make himself king, an attempt thwarted when Nathan acted so that Solomon was crowned instead.
The verse records Adonijah asking, through an intermediary, that Solomon the king give him Abishag the Shunammite as wife.
The passage itself does not explain the reason for the request concerning Abishag.

The request was a shrewd attempt to gain the kingdom, since possessing the former king's concubine could strengthen Adonijah's claim among the fickle people.
The request was part of a plot to seize the throne that was thwarted and ended in Adonijah's death.
The request was a further offense and insult to the king that led to Adonijah's death.
The request comes a little before Adonijah is slain, about the time Joab is also slain for failing in loyalty to his king and Shimei, who had cursed David, is also put to death for failing to abide by his conditions of life.

The events belong to the later history of David in which the judgments announced after his great transgression are shown to have come upon him.
They fulfilled Nathan's warning that violence would continue within David's house.
Adonijah's rebellion and death were part of the retribution that followed David through the rest of his life, principally in his own family, for his wicked conduct toward Uriah.
Like the history of Amnon and Tamar and the rebellion and unnatural crimes of Absalom, it illustrates receiving back in kind for wrongs committed, that sin pays in its own kind.