1 Kings 8:58

That he may incline our hearts unto him, to walk in all his ways, and to keep his commandments, and his statutes, and his judgments, which he commanded our fathers.

The prayer was offered at the dedication of Solomon's temple, built after Israel ended its nearly forty-year pilgrimage from Horeb to Jerusalem and settled in Canaan, following David's desire while dwelling in his palace of cedar to provide a worthy dwelling for the ark of God, which symbolized His presence and still rested in the wilderness tabernacle. It is Solomon's blessing prayer over all Israel at the dedication of the finished temple, spoken after his kneeling prayer with many nations present, when he remained pure and exalted God's law before the people. In that setting it teaches that God is not confined to a built temple like the heathen gods, but meets His people by His Spirit when they assemble in the house dedicated to His worship, tearing away heathen superstitions about Jehovah.

It prays that God would remain with His people as He was with their fathers, not leaving or forsaking them, by inclining their hearts toward Himself to enable them to walk in all His ways and keep His commandments, statutes, and judgments commanded to their fathers. It calls for hearts wholly and undividedly given to the Lord in wholehearted faithfulness and a life of obedience to His ways and commandments.

The verse states the conditions God required of His people in order to receive His blessings in their worship, with sincere worship bringing His blessing. Anger and resentment shut the Spirit of God away from worship. God's being with Solomon lasted only as long as Solomon steadfastly obeyed, as God had been with David, showing God's mercy was given according to truth, righteousness, uprightness of heart, and faithfulness. The verse proves God did not sanction the sins of David and Solomon. Solomon who prayed this for Israel later acted contrary to that prayer, allowing pagan beliefs and worship to corrupt his religion and becoming an apostate and their seducer away from God. Its instruction is to be carried out in family life, with parents teaching and modeling God's word for their children and households acknowledging God as the source of their blessings in reverent, grateful worship expressed in thanksgiving and praise for God's gifts.