God’s promises often require godly action to bring them to fulfillment.
And if thou wilt walk before me, as David thy father walked, in integrity of heart, and in uprightness, to do according to all that I have commanded thee, and wilt keep my statutes and my judgments: Then I will establish the throne of thy kingdom upon Israel for ever, as I promised to David thy father, saying, There shall not fail thee a man upon the throne of Israel. (1 Kings 9:4-5 KJV)
God promised Solomon an if/then or conditional promise hedging upon Solomon’s personal obedience to God’s Word. If Solomon followed God’s commandments; taking them to heart and allowing them to play outwardly in his life all for the honor and glory of God then he could count on God establishing his throne upon Israel forever.
Conditional promises always have another alternative ending when the outcome is not according to the promise of God but rather for when men fall short in keeping God’s statutes. The opposite side of the coin was if Solomon failed to keep God’s law and fall into living against the laws of God including worshipping other gods then He would not fulfill His promise of an everlasting reign of David’s kingdom in Israel.
The outcome and reign of Solomon’s kingdom was at play in his own hands. His success as king depended upon his spiritual allegiance to God and only to God, not his following after the many gods of the world; and not just declaring by mouth his dedication to God but showing it through his actions and lifestyle choices, that his kingdom was built upon the sure foundation of God.
God desired to keep The Davidic Covenant alive through the throne of his son Solomon continuing on forever.