Short answer
God (﷾) does not need our worship, and He gains nothing from it. A Maker who depends on nothing cannot be made greater by praise or smaller by neglect. The Qur'an says people are the ones in need of God (﷾), while He is free of all wants. In a saying the Prophet (ﷺ) reported from God (﷾), the piety of all people together adds nothing to His kingdom. So worship is His due, offered to Him alone, and all its benefit is ours. Praising what truly deserves praise is seeing it rightly, not flattery. Thanking the One who gave us everything makes us grateful people. And everyone gives their deepest loyalty to something. Serving the One who made us frees a person from many masters. Belief, prayer and good character then become one way of life.
Full explanation
What the question takes for granted
One form of the question pictures God (﷾) like a king who enjoys applause. A king gains from praise: it shores up his power and his pride. But the case for God (﷾) is a case for a Maker who depends on nothing. Such a Maker cannot gain anything, because there is nothing He lacks. Praise cannot make Him greater, and neglect cannot make Him less. A being who needed our worship would not be God at all. Philosophers note that the very word "God" is tied to being worthy of worship. So the real question is not what God (﷾) gets from worship. It is why worship is His due, and what it does for the one who worships.
Notes that the word "God" is closely tied in meaning to worship, so that being worthy of worship may be what makes a being God. In some religions, especially certain Western monotheistic ones, he writes, worship means total devotion and unconditional commitment. He adds in passing that it is an open question whether any being could be worthy of such worship from autonomous agents, as most adult humans are. If one could, it would have to be an especially impressive God.
“O ye men! It is ye that have need of Allah: but Allah is the One Free of all wants, worthy of all praise.”
Islam's answer: God (﷾) gains nothing from it
Islam says exactly this. The Qur'an tells people that they are the ones who need God (﷾), and that He is free of all wants (35:15). Whoever strives does so for his own soul, for God (﷾) is free of all needs (29:6). If people reject Him, He has no need of them (39:7). In a hadith qudsi, a saying the Prophet (ﷺ) reported from God (﷾), God (﷾) says His servants can never harm Him or benefit Him. The jinn are unseen beings who, like humans, can choose to obey God (﷾) or not. If every human and jinn had the most pious heart, it would add nothing to His kingdom. If all had the most wicked heart, it would take nothing away (Muslim 2577). The Qur'an even asks what God (﷾) could gain by punishing anyone who is grateful and believes (4:147).
“O ye men! It is ye that have need of Allah: but Allah is the One Free of all wants, worthy of all praise.”
“And if any strive (with might and main), they do so for their own souls: for Allah is free of all needs from all creation.”
“If ye reject (Allah), Truly Allah hath no need of you; but He liketh not ingratitude from His servants: if ye are grateful, He is pleased with you. No bearer of burdens can bear the burden of another. In the end, to your Lord is your Return, when He will tell you the truth of all that ye did (in this life). for He knoweth well all that is in (men's) hearts.”
Later in the long hadith that begins with Allah forbidding injustice to Himself, Abu Dharr reports the Prophet (ﷺ) saying that Allah says: My servants, you can never reach the point of harming Me, nor of benefiting Me. If the first and last of you, humans and jinn, all had the heart of the most pious among you, it would add nothing to My dominion. If all had the heart of the most wicked, it would take nothing from it. If all asked of Me in one place and each were given his request, it would lessen what I have no more than a needle dipped in the sea. It is only your deeds that I count for you and then repay you in full. So whoever finds good, let him praise Allah, and whoever finds otherwise, let him blame only himself. A hadith qudsi: the meaning is given as Allah's, in the Prophet's words.
“What can Allah gain by your punishment, if ye are grateful and ye believe? Nay, it is Allah that recogniseth (all good), and knoweth all things.”
True praise is not flattery
Flattery is praise that is false or overdone, given to win favour. Neither fits here. When we see a brave rescue or a great work, we praise it because it is good. The praise does not feed anyone's ego. It shows that we have seen the thing as it really is. The same holds for thanks. A person who never thanks those who helped him is the poorer for it, not they. Gratitude is part of a sound character. If there is a Maker who gave us life and everything in it, then praising and thanking Him is simply seeing things truly. Still, worship is not mainly a tool for feeling better. If there is a Maker, a life that never thanks Him is out of line with what is real, however calm it feels.
“Praise be to Allah, the Cherisher and Sustainer of the worlds;”
“we bestowed (in the past) Wisdom on Luqman: "Show (thy) gratitude to Allah." Any who is (so) grateful does so to the profit of his own soul: but if any is ungrateful, verily Allah is free of all wants, Worthy of all praise.”
Islam's answer: thanks is a gain for the one who gives it
The Qur'an opens with praise of God (﷾), the Lord of the worlds (1:2). It also says who gains from that praise. Luqman, a wise man the Qur'an honours, was told to give thanks to God (﷾). Any who is grateful does so to the profit of his own soul (31:12). Solomon said that whoever is grateful is grateful for his own soul's good, and that his Lord is free of all needs (27:40). God (﷾) says He is pleased when people are grateful, and He does not like ingratitude in them (39:7). Being pleased is not the same as being in need. A good teacher is pleased when a pupil learns, though the learning is the pupil's gain. Nor is worship in Islam born of fear alone. It joins love, hope and fear. The Qur'an says those of faith are overflowing in their love for God (2:165), and it names Him Full of Loving-Kindness (85:14).
“Praise be to Allah, the Cherisher and Sustainer of the worlds;”
“we bestowed (in the past) Wisdom on Luqman: "Show (thy) gratitude to Allah." Any who is (so) grateful does so to the profit of his own soul: but if any is ungrateful, verily Allah is free of all wants, Worthy of all praise.”
“Said one who had knowledge of the Book: "I will bring it to thee within the twinkling of an eye!" Then when (Solomon) saw it placed firmly before him, he said: "This is by the Grace of my Lord!- to test me whether I am grateful or ungrateful! and if any is grateful, truly his gratitude is (a gain) for his own soul; but if any is ungrateful, truly my Lord is Free of all Needs, Supreme in Honour!"”
“If ye reject (Allah), Truly Allah hath no need of you; but He liketh not ingratitude from His servants: if ye are grateful, He is pleased with you. No bearer of burdens can bear the burden of another. In the end, to your Lord is your Return, when He will tell you the truth of all that ye did (in this life). for He knoweth well all that is in (men's) hearts.”
“Yet there are men who take (for worship) others besides Allah, as equal (with Allah): They love them as they should love Allah. But those of Faith are overflowing in their love for Allah. If only the unrighteous could see, behold, they would see the penalty: that to Allah belongs all power, and Allah will strongly enforce the penalty.”
“And He is the Oft-Forgiving, Full of Loving-Kindness,”
Worship is His due, and its benefit is ours
The Qur'an says God (﷾) created jinn and humans only to serve Him (51:56). The very next verse says He wants no provision from them and no food (51:57). So worship is not for His need. It is His due, for He is worthy of all praise (35:15). It is offered sincerely to Him alone (98:5), and all its benefit comes back to us. Worship shapes the one who does it. Prayer holds a person back from shameful and unjust deeds (29:45). Hearts find rest in the remembrance of God (13:28). In the same hadith qudsi, God (﷾) says it is only people's own deeds that He counts and then repays in full (Muslim 2577). In Islam, belief, worship and conduct belong together as one way of life. The page on the purpose of life sets out more.
“I have only created Jinns and men, that they may serve Me.”
“No Sustenance do I require of them, nor do I require that they should feed Me. For Allah is He Who gives (all) Sustenance,- Lord of Power,- Steadfast (for ever).”
“O ye men! It is ye that have need of Allah: but Allah is the One Free of all wants, worthy of all praise.”
“And they have been commanded no more than this: To worship Allah, offering Him sincere devotion, being true (in faith); to establish regular prayer; and to practise regular charity; and that is the Religion Right and Straight.”
“Recite what is sent of the Book by inspiration to thee, and establish regular Prayer: for Prayer restrains from shameful and unjust deeds; and remembrance of Allah is the greatest (thing in life) without doubt. And Allah knows the (deeds) that ye do.”
“"Those who believe, and whose hearts find satisfaction in the remembrance of Allah: for without doubt in the remembrance of Allah do hearts find satisfaction.”
Later in the long hadith that begins with Allah forbidding injustice to Himself, Abu Dharr reports the Prophet (ﷺ) saying that Allah says: My servants, you can never reach the point of harming Me, nor of benefiting Me. If the first and last of you, humans and jinn, all had the heart of the most pious among you, it would add nothing to My dominion. If all had the heart of the most wicked, it would take nothing from it. If all asked of Me in one place and each were given his request, it would lessen what I have no more than a needle dipped in the sea. It is only your deeds that I count for you and then repay you in full. So whoever finds good, let him praise Allah, and whoever finds otherwise, let him blame only himself. A hadith qudsi: the meaning is given as Allah's, in the Prophet's words.
Then why hold anyone to account?
The sharper form of the objection is a dilemma. If God (﷾) gains from worship, He is needy. If He gains nothing, why ask for it, and why judge those who refuse? The first half fails, as shown above. The second half treats refusing as a private choice that wrongs no one. But turning from the One who gave us everything is ingratitude. Giving His due to others is a real wrong. And God (﷾) judges with full justice. The Qur'an says no one is punished before a messenger has come (17:15). God (﷾) alone judges what each person was given. A judge who repays wrongs is not wounded by them. He is just.
“O ye men! It is ye that have need of Allah: but Allah is the One Free of all wants, worthy of all praise.”
“Behold, Luqman said to his son by way of instruction: "O my son! join not in worship (others) with Allah: for false worship is indeed the highest wrong-doing."”
“Who receiveth guidance, receiveth it for his own benefit: who goeth astray doth so to his own loss: No bearer of burdens can bear the burden of another: nor would We visit with Our Wrath until We had sent a messenger (to give warning).”
Islam's answer: God (﷾) wrongs no one; people wrong their own souls
The Qur'an records Luqman telling his son that worshipping others besides God (﷾) is the highest wrong-doing (31:13). It says God (﷾) does not wrong anyone at all. It is people who wrong their own souls (10:44). He is never unjust in the least, and He doubles every good deed (4:40). In the hadith qudsi, God (﷾) says He has forbidden injustice to Himself. He counts only people's own deeds and repays them in full (Muslim 2577). The page on whether Hell lasting for ever is fair sets out more.
“Behold, Luqman said to his son by way of instruction: "O my son! join not in worship (others) with Allah: for false worship is indeed the highest wrong-doing."”
“Verily Allah will not deal unjustly with man in aught: It is man that wrongs his own soul.”
“Allah is never unjust in the least degree: If there is any good (done), He doubleth it, and giveth from His own presence a great reward.”
Abu Dharr reports the Prophet (ﷺ) saying that Allah says: My servants, I have forbidden injustice to Myself and made it forbidden among you, so do not wrong one another; all of you are astray except those I guide, so ask Me for guidance; you sin by night and day and I forgive all sins, so ask Me for forgiveness. A hadith qudsi: the meaning is given as Allah's, in the Prophet's words.
Later in the long hadith that begins with Allah forbidding injustice to Himself, Abu Dharr reports the Prophet (ﷺ) saying that Allah says: My servants, you can never reach the point of harming Me, nor of benefiting Me. If the first and last of you, humans and jinn, all had the heart of the most pious among you, it would add nothing to My dominion. If all had the heart of the most wicked, it would take nothing from it. If all asked of Me in one place and each were given his request, it would lessen what I have no more than a needle dipped in the sea. It is only your deeds that I count for you and then repay you in full. So whoever finds good, let him praise Allah, and whoever finds otherwise, let him blame only himself. A hadith qudsi: the meaning is given as Allah's, in the Prophet's words.
Everyone serves something
Some say worship is servility, unworthy of free people. But everyone gives his deepest loyalty to something. For some it is money, a career or other people's approval. For others it is family, friends or a cause, and these are good things. Yet even good loyalties pull in different directions, and none of them made us. None can judge between the others, and any of them can be lost. The real choice is not between serving and being free. It is between many masters and the One who made us and needs nothing from us.
“Allah puts forth a Parable a man belonging to many partners at variance with each other, and a man belonging entirely to one master: are those two equal in comparison? Praise be to Allah! but most of them have no knowledge.”
“"O my two companions of the prison! (I ask you): are many lords differing among themselves better, or the One Allah, Supreme and Irresistible?”
Islam's answer: one Master frees a person from many
The Qur'an gives this as a parable. One man belongs to many partners who quarrel with each other. Another belongs entirely to one master. Are the two equal (39:29)? Joseph asked his two fellow prisoners the same thing. Are many lords who differ among themselves better, or the One God (12:39)? A person who serves God (﷾) alone need not be ruled by fashion, fear of people or greed. Nor does Islam ask for blind faith. The Qur'an praises those who remember God (﷾) and also reflect on the creation of the heavens and the earth (3:190-191). Obeying God (﷾), once a person has good reason to trust Him, is trust, not blindness.
“Allah puts forth a Parable a man belonging to many partners at variance with each other, and a man belonging entirely to one master: are those two equal in comparison? Praise be to Allah! but most of them have no knowledge.”
“"O my two companions of the prison! (I ask you): are many lords differing among themselves better, or the One Allah, Supreme and Irresistible?”
“Behold! in the creation of the heavens and the earth, and the alternation of night and day,- there are indeed Signs for men of understanding,- Men who celebrate the praises of Allah, standing, sitting, and lying down on their sides, and contemplate the (wonders of) creation in the heavens and the earth, (With the thought): "Our Lord! not for naught Hast Thou created (all) this! Glory to Thee! Give us salvation from the penalty of the Fire.”
If God (﷾) needs nothing, why create at all?
Creating is giving, not getting. The Qur'an says God (﷾) is the One who gives all sustenance, and wants none from His creatures (51:57-58). It names the purpose He gave us: to serve Him (51:56). It names the test too: He made death and life to try which of us is best in deed (67:2). Beyond what God (﷾) has told us, Islam does not guess at His reasons. What He has told us is enough to answer the charge. He made us to serve Him, and the good of that service is ours, not His.
“No Sustenance do I require of them, nor do I require that they should feed Me. For Allah is He Who gives (all) Sustenance,- Lord of Power,- Steadfast (for ever).”
“I have only created Jinns and men, that they may serve Me.”
“He Who created Death and Life, that He may try which of you is best in deed: and He is the Exalted in Might, Oft-Forgiving;-”
The replies answered
Qur'an 39:7 — Surat al-Zumar (The Groups), verse 7
“If ye reject (Allah), Truly Allah hath no need of you; but He liketh not ingratitude from His servants: if ye are grateful, He is pleased with you. No bearer of burdens can bear the burden of another. In the end, to your Lord is your Return, when He will tell you the truth of all that ye did (in this life). for He knoweth well all that is in (men's) hearts.”
Cited for
If God does not need us, why does He punish those who refuse to worship Him? That sounds like a wounded ego.
The response
The same verse says God (﷾) has no need of those who reject Him (39:7). Judgment is not God avenging a loss. It is justice for what people did. Giving God's (﷾) due to others is itself a wrong, and Luqman calls it the highest wrong-doing (31:13). God (﷾) wrongs no one; people wrong their own souls (10:44). In the hadith qudsi, God (﷾) says He counts only people's own deeds and repays them in full (Muslim 2577).
Where it lands — Judgment in Islam is the repayment of people's own deeds. Nothing in it is God's (﷾) loss or gain.
Atheism and Agnosticism (Stanford Encyclopedia of Philosophy, 2022)
Notes that the word "God" is closely tied in meaning to worship, so that being worthy of worship may be what makes a being God. In some religions, especially certain Western monotheistic ones, he writes, worship means total devotion and unconditional commitment. He adds in passing that it is an open question whether any being could be worthy of such worship from autonomous agents, as most adult humans are. If one could, it would have to be an especially impressive God.
Cited for
Worship means unconditional obedience. A free moral agent cannot hand over his conscience, so no being could deserve worship.
The response
A person with good reason to judge that God (﷾) is perfectly good and knows all things uses his conscience when he trusts Him. He does not give it up. Such a God never commands what is shameful (7:28). And no one lives without some highest loyalty. Serving the One who made us, and needs nothing from us, frees a person from lesser masters (39:29).
Where it lands — Trusting a perfectly good God (﷾) is conscience at work, not conscience surrendered.
Qur'an 39:7 — Surat al-Zumar (The Groups), verse 7
“If ye reject (Allah), Truly Allah hath no need of you; but He liketh not ingratitude from His servants: if ye are grateful, He is pleased with you. No bearer of burdens can bear the burden of another. In the end, to your Lord is your Return, when He will tell you the truth of all that ye did (in this life). for He knoweth well all that is in (men's) hearts.”
Cited for
The Qur'an says God is pleased when people are grateful. A being who wants praise, and is pleased by it, sounds vain.
The response
Vanity is needing praise to feel one's worth. A Maker who lacks nothing cannot need it. The same verse that says He is pleased says He has no need of us (39:7). He is free of all needs from all creation (29:6). A good teacher is pleased when a pupil learns, though the gain is the pupil's. He is pleased when we give thanks, and the good of it is ours, not His (31:12).
Where it lands — Being pleased is not needing. God (﷾) is pleased by our thanks, and the good of it is ours.
The Natural History of Religion (1757)
Gives an account of how belief in one God arose. People first feared unknown causes and tried to win over invisible powers by prayer and sacrifice. Over time one god was singled out. In their anxiety to please and praise him, worshippers outdid one another in the perfections they gave him, until they called him infinite and perfect. Hume's aim is to show that belief in God, as people actually hold it, rests not on reasoning but on fear and ignorance.
Cited for
Hume argued that belief in one God grew out of fear, not reasoning. People tried to please and praise a god, and the praise grew until they called him perfect. On this view, worship is flattery.
The response
Hume tells how people came to praise, and means it to show that belief does not rest on reason. But a story of how people came to a belief cannot show that no good reasons for it exist. The reasons for a Maker who depends on nothing must be met on their own terms. Flattery is praise that is false or overdone, given to win favour. God (﷾) gains nothing from praise (Muslim 2577), and the one who gives thanks is the one who gains (31:12).
Where it lands — The charge of flattery needs a God who gains from praise. God (﷾) gains nothing from it, so the charge does not reach Him.
Qur'an 51:56 — Surat al-Dhariyat (The Winnowing Winds), verse 56
“I have only created Jinns and men, that they may serve Me.”
Cited for
If God created us to worship Him, He must want something from us. And if He needs nothing, why create at all?
The response
The next verse answers the first half: He wants no provision from His creatures and no food (51:57). He is the One who gives all sustenance (51:58). Creating is giving, not getting. The Qur'an names the purpose (51:56) and the test of who is best in deed (67:2). Islam does not guess beyond what God (﷾) has said.
Where it lands — God (﷾) made people to serve Him, and the good of it is theirs, not His. Islam claims no more than that.
Perspectives
Worship born of fear, not reason
Hume held that belief in one perfect God grew out of fear, not reasoning. People tried to win over unseen powers, and outdid one another in praising one god until they called him perfect.
David Hume, The Natural History of Religion (1757)
Belief in a perfect God grew out of fear, not reasoning. People tried to please and praise one god, each outdoing the last, until they called him perfect.
Rebuttal
Hume's story is meant to show that belief in God (﷾) does not rest on reason. But the case for a Maker does not start from praise or fear. It starts from a world that depends on something that depends on nothing. Those reasons stand however worship began. And praising a god to win his favour treats him as someone who gains from praise. A Maker who lacks nothing gains nothing from it (35:15; Muslim 2577).
Worship and moral autonomy
Worship means unconditional obedience. A moral agent may not hand over his own judgment of right and wrong. So no being could deserve worship, and since God by definition deserves it, there is no God.
An argument in philosophy of religion; Paul Draper notes the question in the Stanford Encyclopedia of Philosophy
Worship asks a person to obey without question. A moral agent cannot give up his own judgment, so no being can rightly be worshipped.
Rebuttal
Judging that a being is perfectly good and knows all things, and then trusting Him, is moral judgment at work, not given up. We do the same, in a small way, with an honest doctor. A perfectly good God (﷾) never commands what is shameful (7:28). He commands justice and good (16:90). Islam asks for faith reached by reflection (3:190-191).
The Islamic perspective
God (﷾) is free of all needs and gains nothing from worship. Worship is His due, offered to Him alone, and its benefit is the worshipper's. It is honest praise, gratitude and service of the One who made us, and it frees a person from many masters.
The Qur'an says people are in need of God (﷾). He is free of all wants, and has no need of them.
In a hadith qudsi, God (﷾) says His servants can never harm or benefit Him. The piety of all of them together would add nothing to His kingdom.
Worship is God's (﷾) due, offered sincerely to Him alone.
Gratitude to God (﷾) profits the soul of the one who is grateful.
God (﷾) created jinn and humans to serve Him, and wants no provision from them.
Worship shapes the worshipper: prayer restrains from wrong, and remembrance of God (﷾) brings hearts to rest.
Serving the One God (﷾) frees a person from serving many masters.