The divine promise granted to Solomon establishes a clear boundary between absolute gifts and rewards earned through personal actions. While God previously promised Solomon immense wealth and honor without any strings attached, the gift of a long life comes with a strict requirement. To achieve this, Solomon must actively walk in the ways of God.
The commentators explain the reasoning behind this distinction. The Torah never placed prior limits on a king receiving wealth and honor, allowing God to grant them to Solomon as an unconditional gift, regardless of whether he remained righteous. In contrast, the Torah explicitly dictates that a king's long life and the survival of his dynasty depend entirely on his obedience to the Commandments. God maintains this fundamental rule, keeping the promise of a long life completely conditional [רש״י].
History ultimately proved the reality of this condition. Because Solomon did not perfectly observe the Commandments of God throughout his entire reign, he did not achieve the promised long life, passing away at the age of fifty-two. Yet, the unconditional promises were fully realized, and immense wealth and honor accompanied him throughout his entire life [רד״ק].