The real purpose of tefillah is not so much for it to be answered, but rather to demonstrate that the only One to Whom it makes sense to daven is Hashem. We daven because we recognize that we are absolutely helpless and that only He can provide our needs, and Hashem rewards us accordingly.
Based on this, we can answer a major question regarding the concept of prayer. It would be improper to request something repeatedly from a human king, especially if that request has already been refused; it would only anger the king. But we make the same eighteen requests of Hashem three times each day – morning, afternoon, and evening. Even though most of these things have not been granted to us, we continue to ask for them each day. This is because the purpose of tefillah is to demonstrate that only Hashem can grant us our needs, and Hashem knows when and whether to grant them.
(Beis Elokim, Shaar Tefillah, ch. 2)