Solomon is praying his prayer at the dedication of the temple. He’s acknowledged God’s character and has pleaded for mercy when they sin. He asks God to give to each according to His ways, according to what’s in their hearts.
The point is that they would fear God and walk in His ways in the land He’s given them. So, what goes wrong?
God keeps His end of the deal. God hears and answers prayer. But His ways are not our ways. We see blessing as one thing; God sees it as another. Abraham was blessed in wealth, but not in children. David was blessed with God’s on presence, His Spirit with Him and speaking through Him, yet David was attacked by enemies on all sides.
Psalms like Psalm 37 speak of the wicked prospering, but it also repeatedly points out how they will be cut off, how they have no future. It’s David and his descendants that will inherit the land and dwell forever. It also speaks of how the little the righteous has is better than the wealth of the wicked.
There is a blessing beyond material things. People tend to get caught up in material things. They get the idea that happiness is in having what they don’t have and so are unhappy and seeking things instead of being thankful for what they do have and thankful to the one who has given them all they have and life itself.
If we acknowledged God’s goodness and love and perfect ways, we could honor Him and fear Him and love Him no matter the circumstances. He can help us see at least in part all that He is working out and in through the circumstances for our benefit.
He sees your heart and is giving you what you desire. That could be a good or a bad thing. If our heart is set on Him, then the thing we are getting is Him or what we need to get us turned back to Him.
If our heart is set on something else, hopefully someone is praying for us so God won’t give us what we desire, but will give us what will turn us to Him.
If we love the Lord with our whole heart, then we can walk in the joyful knowledge that He’s giving us the desire of our hearts, Him. We’re growing in Him, receiving more of Him and losing more of ourselves, to the joyful end of being like Christ and having new hearts that know and love the Lord alone.