Whatever we do must be to glorify God (1 Corinthians 10:31). The purpose of prayer must always be to glorify God.
Whatever you ask in my name, this I will do, that the Father may be glorified in the Son. (John 14:13)
Praying in Jesus’ name means that when a Christian comes to the Father in prayer, they come as Jesus’ representative. In other words, when we pray in His name, we claim to be acting for Him. This is akin to what we know as a power of attorney. A person with a power of attorney has the legal right to make decisions for another. They are acting in that person’s stead. However, it is limited only to the authority granted. The person with a power of attorney is acting in the place of the person who has given the power of attorney. Any decision outside the authority granted in the power of attorney is not valid and cannot be enforced. When a Christian prays in Jesus’ name, they are acting for Him. However, a Christian can only act within the realm of the Father’s will as Jesus did (Luke 22:42, John 5:30, John 6:38, Hebrews 10:7). Jesus glorified the Father in all that He did and as such, if we are acting in His stead in our prayers, it stands that our prayers will glorify God.
If we ask anything according to His will, He will hear us (1 John 5:14).
Whatever we ask is united or tied to God’s glory. In other words, only requests that are seeking God’s glory is properly motivated and answered. Three times Paul pleaded with God to remove the thorn in his side (2 Corinthians 12:7). God denied Paul his request and answered that His grace is sufficient and that His power is made perfect in weakness (2 Corinthians 12:9). God’s was glorified in denying Paul his request because God’s power was made perfect in Paul’s weakness. Paul stated “Therefore I will boast all the more gladly of my weaknesses, so that the power of Christ may rest upon me.” Paul’s prayer request to have the thorn in his side remove was a valid petition of God. However, it glorified God to not grant Paul’s request because it glorified God so much so that Paul boasted of his weakness so that the power of Christ would rest upon him.