The succession of Solomon to the throne of David wasn’t secure even through the final days of the old king’s life.
Like his brother Absalom before him, Adonijah declared himself king over Israel before the death of David. The difference is that Adonijah’s insurrection took place after David publicly named Solomon his heir and successor.
We discuss the political machinations of Adonijah and why Solomon had him killed for asking to have David’s concubine Abishag for a wife. In a nutshell, Adonijah’s request was a not-very-subtle play to show Israel that he, not Solomon, was the true king by demonstrating that he’d inherited the old king’s harem.