God offered to give Solomon whatever he asked for, but God already knew what Solomon would ask for. God knows everything: in the past, the future, and the present. He would not have made such a generous offer if Solomon would have asked for riches or a long life or the death of his enemies. Since Solomon wanted something that God wanted to give him, God offered to give him whatever he wanted.
Has God offered you whatever you want? No? Me neither. The problem could be that God is not as generous as he used to be, but that makes no sense. The problem surely is that I do not yet want what God wants to give me. God will happily be generous as soon as I am receptive.
Yet God has offered to give us his gift: the Holy Spirit, God himself. What else could we possibly want? Would we want money or fame or any other worldly possession? No. Who would want money or fame except because they think it will make them happy? Who wants anything at all except because they think that it will make them happy?
The problem is whether I believe that the Holy Spirit will make me happy. If I really believed that a life of serving God and my neighbor would make me happy, I would not do anything else. The essential problem of sin is a failure to believe that God is the source of my happiness. Eve ate the fruit because she failed to believe that God would make her happy. Every sin that has ever been committed has been done for this reason.
If only I would believe in the happiness God has to offer, how happy I would be! There is no failure of generosity on his part. He is ready to give me the happiness that my soul desires. I, however, for whatever reason I know not — pride, foolishness, fear, or all these things — will seek happiness everywhere except the one place that I am sure to get it.
Solomon eventually rejected the wisdom that God gave him; in his old age, he became a fool, worshiping other gods to please his wives, but in this one glorious moment Solomon did not ask anything for himself except the wisdom to accomplish the task God had given him. He is an example for us, that when we forget ourselves we will finally be happy.