In other words, we all know that Allah (swt) is needless of all things, so we have to justify Him ordering us to worship Him by saying that it is for ourselves. The question is that is all of this worship, prayer, dhikr, standing before Allah (swt) and praising Him really only for us? To tell you the truth, the phrase “for us” bothers me, because it takes away the sweetness of worship from me. I don’t know what to say…I mean if this is the case, then was the imams’ worship only for themselves? For them to reach higher levels of spirituality? This doesn’t seem to be something good and beautiful, and isn't convincing either. If so, then what does this saying of Imam Ali (as) mean: “Some worship Allah (swt) out of fear from the hellfire, some worship Him out of eagerness for heaven, and some do it just for Him.”?
Aren't the two first groups the imam mentions worshipping Allah (swt) for themselves (their desires and comfort) and aren't they inferior to the third group who do it just for Him? If so, then what does it mean that the third group does it just for Him, while He is the All-Sufficient?
Since Allah (swt) is the All-Wise and doesn’t ever order anyone to do anything that is useless, all of our worship that He himself has commanded us to perform bears benefits for us, and since He is All-Sufficient in essence and has no need for any of our worship, these benefits are all for those worshipping and sometimes others as well.
These benefits and effects are in no way in conflict with our intentions for worshipping Him; meaning that although the purified individual performs worship only for Allah (swt), it doesn’t mean there is nothing in it for the individual himself. The intentions of those who worship varies depending on their mindsets and level of understanding and insight, and the prophets and imams, who are at the highest of these levels, bear the best and purest intentions, which is that they worship Him out of gratitude and considering Him to be the only one deserving to be bowed down to. The more sincere and pure the intention of worship is, the more it will benefit the one performing it.
From another perspective, man bears two dimensions; heavenly and materialistic desires, hence, bearing two “selfs”, one being for real and the other not. What Islam reprehends is for one to strive for the materialistic “self” (which isn't the real “self”), but striving to enhance and perfect the true “self” is actually considered striving in the way of Allah (swt) and for Him. If one’s intention for worship is to perfect this dimension, and to draw nearer to the Lord, his worship will certainly be in line with the worship of Allah (swt) and will not stray the least from the right path.
The answer to your question can be divided into two parts:
1- Although it is true that all forms of worship have benefits for those performing them, nevertheless, the infallibles never did it for the benefits and advantages they might entail; they would only do it for Allah (swt) himself, not for themselves.
In order to further explain this answer, a few points need to be taken into consideration:
a) Clearly, different forms of worship all have their benefits and spiritual advantages, and none of them are totally useless, because if it was so, Allah (swt) wouldn’t have ordered us to perform them and wouldn’t vow to punish those who don’t. At the same time, we are sure that none of these benefits are for Allah (swt), as He is the All-Sufficient and in no need of anything; they have no affect on His high rank, because it isn't possible for there to be any other rank higher than His that He needs to attain; all creatures and things are only a small particle of the sea of His never-ending magnanimity. He is All-Sufficient in essence, and doesn’t need anyone to give Him anything, because He doesn’t lack anything, and no one can do Him any harm, so that He can prevent it with the worship of His sincere servants.
So the effect of worship can only be found in the worshipper and other people and beings, regardless of who the worshipper is, let it be a normal person or one of the infallibles. Of course the difference between normal people and the infallibles is that the infallibles are benefited from their worship much more than normal people, the reason being that they perform their worship with much more insight and understanding of Allah (swt).
b) The spiritual advantages and benefits of worship, which are the goals of the worship itself, shouldn’t be mixed with the goals and motives of the worshipper himself (so there are two things here: the goals of the act itself, and the goals of the one performing the act), and there is nothing wrong with the motive of the worshipper being the goals of worship (which were the benefits and advantages it entails).
It isn't a bad idea to explain the difference between the goal of the worshipper and the goal of worship with an example:
Assume there is this medication for a sick person that will cure him from his disease that he refuses to take. At the same time, his dad insists on him taking it. The sick person takes the medicine not because of its curing effects, but just because his father has asked him to. What we are trying to say is that it isn't necessary for the goal of the action and what it entails to always be the same as the goal of the person doing it.
Having said that, although Allah (swt) is the most grateful of all and never leaves anything done for His cause without appreciation, there are individuals who would still worship Allah (swt) even if they knew He wouldn’t give them anything in return and it wasn’t to their advantage and benefit at all, just because He has asked them to; we believe the imams to be of these individuals.
c) The worshipper’s motive for worshipping is what determines how much the act will have an impact and how much it will benefit the one performing it; the more the worshipper is sincere, the more good effects the worship will have, both in quality and amount. In reality, as long as worship isn't done for Allah (swt), it has no effect, and only has an effect if it is done for Him. There is one point that needs to be noted though, which is that doing something for Allah (swt) has different levels; “Some worship Allah (swt) out of eagerness for paradise, this is the worship of merchants (it isn't very valuable), some worship Him out of fear of the Hellfire, this is the worship of slaves (it isn't very valuable either) and some do it out of gratitude for His blessings and because they consider Allah (swt) to deserve being worshipped, this is the worship of the free men (it is very effective and beneficial).” This precious and important saying of Imam Ali (as) is pointing to the motive of the worshipper and tells us that although one doesn’t distance from Allah (swt) and His obedience when he worships him for heaven or out of fear of hell (because He is the one who has asked us to do so even with such motives and also since He is the one who has placed these benefits for worship), nevertheless, he needs to strive to reach a level in which he worships Allah (swt) only for Him.
As was said, when one worships Allah (swt) only for Him, it is to his own benefit as well, helping him attain the rank of pleasing Allah (swt) and His nearness, while at the same, such things were in no way his motive (and he only did it for Allah (swt)).
One who reaches such a level of sincerity sees worship as a way to be “intimate” with Allah (swt), one who is in love only thinks of reaching the one he/she loves, to the extent that he/she wants nothing and puts his/her existence on the line for the beloved.
2- The other answer is to say that man consists of two dimensions; a heavenly and bodily one which are also referred to as “the true self” and “the false self” respectively. What Islam reprehends and considers struggling against to be the “Great Jihad”, is the false self and its desires, and what the Quran means when it says that the biggest loss is for one to lose (ruin) oneself, is the true self.
This “self” is a reality that the Quran speaks about: “And do not be like those who forget Allah, so He makes them forget their own selves”. This means that one will find this self when he finds Allah (swt), and that is why it is said that discovering of the self is never apart from the disclosure of Allah (swt). Not only isn't one not supposed to struggle against this true self, but has to honor it, this being the reason for why we have no right to embarrass ourselves in front of others (and that no one can say I belong to myself and can do anything I want about it).
As Shahid Mutahhari puts it, “The core and essence of worship which is the remembrance of Allah (swt), is none other than recovering the true self. One finds his true self in worship and in paying attention to Him.”
Anyway, if one’s intention for worshipping is to heighten this dimension and get nearer to Allah (swt), his worship will totally be in line with worshipping Allah (swt) and will not stray the least from the straight path. The worship of the infallibles was of this genre and we have to strive to make our worship the same.
If this is the case with anyone, it will be praiseworthy for him to be “selfish”, meaning that it is a good thing for him to recognize his divine value and love it and not lose it and try to increase it instead, the reason being that such selfishness for the true self isn't actually selfishness, it is loving Allah (swt) and wanting things for Him. Therefore, what Islam doesn’t encourage is for one to strive for the bodily and material self, but encourages for one to strive for the spiritual and heavenly one, which is in reality, striving for Allah (swt) and in His way.
This matter even applies to those who are hired to perform certain rituals for others as well, like those who are paid to perform others’ hajj; if they do it with the intention of boosting their true selves, their intention will also be good and praiseworthy.
 “Those who out of vain arrogance avoid worshipping Me, they will surely enter the Hell while they are disgraced.” Ghafir:60.
 The benefits and advantages of worship have been pointed to in the Quran and hadiths, for instance, in explanation of the reason why fasting has been made obligatory, the Quran says: “لعلکم تتقون” (so that you may become pious) Baqarah:183. Or, Lady Fatimah (as) adds humility to the benefits of prayer, saying: “Allah (swt) has made prayer mandatory so that the people obtain humility…” Biharul-Anwar, vol. 82, pg. 209; Mizanul-Hikmah, vol. 5, pg. 375. This is one of the reasons why it is said that worship is a method of building and purifying people and naturally, when the individual is purified, society will also be purified, because society is made up of these individuals. For further information on the benefits and effects of worship, we recommend: Ayatullah Javadi Amoli, Hekmate Ebadat.
 Nahjul-Balaghah, short saying 237.
 “قَالَ رَسُولُ اللَّهِ (ص): "أَفْضَلُ النَّاسِ مَنْ عَشِقَ الْعِبَادَةَ فَعَانَقَهَا وَ أَحَبَّهَا بِقَلْبِهِ وَ بَاشَرَهَا بِجَسَدِهِ وَ تَفَرَّغَ لَهَا فَهُوَ لَا یُبَالِی عَلَى مَا أَصْبَحَ مِنَ الدُّنْیَا عَلَى عُسْرٍ أَمْ عَلَى یُسْرٍ” The holy prophet of Islam (pbuh) says: “The best of all people is one who loves worship, embraces it and feels it with all of his heart and frees himself [his time] for it, it is then that he will not worry about how his life will be; hard or easy.” Kafi, vol. 2, pg. 83.
 This self has different levels, it begins with self-centeredness and ends with psychological difficulty; see: Morteza Motahhari, Ensane Kamel, pp. 216-225.
 See: Zumar:15.
 See: Hashr:19.
 See: Ensane Kamel, pg. 236.
 For further information refer to: Ibid, pp. 225-244.
 Ibid, pp. 237 and 238.
 In this case, although the rewards of the worship are for the one hiring, but when one does worship without riya (to show to others) and does it only for Allah's (swt) sake, it has many good benefits. Now, the intention of the one performing the worship can be one of three things:
1- To reach those good spiritual benefits
2- Only to get the money being paid to him
3- To reach both
The second might seem inappropriate at first sight, but the truth of the matter is that one general rule can't be issued regarding it, because although this person’s motive might not be to reach the good spiritual benefits, but if his intention is to make money so that he won't have to ask for help from others, thus protecting his true self from degradation, this is still considered striving for the true self and in other words, this worship also has positive spiritual benefits (please pay attention to the fact that the money is the motive for him to get closer to Allah (swt), but why he wants the money is another story; it can have different reasons; so getting money for worship of this sort isn't in conflict with doing it for Allah (swt) and the true self and the two can co-exist).