All divine prophets, regardless of their different degrees and ranks, are infallible and at the peak of nearness to Allah (swt), and all of them have responsibilities that surpass those of normal people to the extent that any attention they give to anything other than Allah (swt) is a great sin for them.
There have been many efforts by different Islamic scholars in explanation of Prophet Musa’s (pbuh) act and how it doesn’t come into conflict with his infallibility, and each has his own explanation.
The best explanation though, is the one that says that he hasn’t committed any sin by doing so, and the only thing that was wrong about what he did was that he could have made a better choice than what he did, yet what he did wasn’t a sin (resulting in him not being infallible). It has been stated that killing the Egyptian man (which was affiliated with the Pharaoh) wasn’t a forbidden act for certain reasons, although it would have been better if Prophet Musa (pbuh) hadn’t killed him because of the negative consequences.
The way the Quran refers to Prophet Musa’s (pbuh) action also in no way discredits his infallibility. For instance, in response to Ma’mun’s (the ruler of Imam Ridha’s (as) time) question about Prophet Musa (pbuh) saying “This is of Satan's doing. Indeed he is an enemy, manifestly misguiding” or saying “Oh my Lord! I have indeed wronged myself, forgive me!”, Imam Ridha says “What is meant by “This is of Satan’s doing” is the quarrel between the two men, not what Prophet Musa (pbuh) did, and what is meant by “I have wronged myself” is that Musa (pbuh) shouldn’t have entered the city, and “forgive me” is referring to Musa (pbuh) hiding from the Pharaoh’s men.”
In order to answer this question, a few points need to be made:
a) A brief explanation of infallibility:
Ismah or infallibility literally means to be protected or to make hold of something and in theological terms refers to a form of grace (bestowed by Allah (swt) upon anyone He desires) that makes one have no tendency to commit a forbidden act or not do an obligatory one, while being completely free and capable of doing so.
b) Some of the reasoning that proves the infallibility of the prophets:
1- One of the main reasons for sending the prophets is for them to inform the people of what is truly to their benefit and harm and to pave the way to their perfection and salvation and prosperity in this life and the next through training and purification of the soul, while such a purpose will be totally defeated in the case of them not being infallible. That is because if they were to commit sins, it is either necessary for us to follow them or not; if it isn’t, there will be no reason in sending them, because they have been sent to be followed, and if it is still necessary to follow them, that means we have to follow them in sinning, which makes no sense.
2- The sinning of a prophet, regardless of whether it is done before or after his prophethood, causes the people to dislike and not follow him.
Considering these and the many other reasons that have been mentioned for the infallibility of the prophets, it is for sure that they are infallible.
c) How aren’t some of the verses of the Quran (like the story of killing the Egyptian man) not in conflict with Prophet Musa’s infallibility?
The Holy Quran says: “And Musa entered the city at a time that people were busy and nobody noticed his arrival, he found two men; One of his followers and one of his Enemies who were quarrelling. The one who was of his people cried for help; so Musa struck his foe with his fist resulting in his death. Musa said reproaching himself:" This is on account of Satan's interference, surely he is an enemy which leads man astray quite openly."
Musa prayed:" O my Creator and Nurturer! I wronged myself, please forgive me." So Allah bestowed His mercy upon him since He is the Merciful Forgiving.”
The question is, when Prophet Musa (pbuh) says: “This is on account of Satan's interference, surely he is an enemy which leads man astray quite openly.” or when he says: “O my Creator and Nurturer! I did wrong to myself, please forgive me!”, how is this not in conflict with his infallibility? Doesn’t what he says imply that he isn’t infallible?
The story of Prophet Musa (pbuh) and the Egyptian man goes like this: One of the Pharaoh’s men forced one of Prophet Musa’s (pbuh) followers to collect some firewood, sparking a quarrel between the two. In an attempt to help his follower, Prophet Musa strikes the Egyptian with his fist in the chest, resulting in his death. What commentators of the Quran have said about Prophet Musa’s (pbuh) act is that he did the wrong thing meaning that he could have made a better choice, and as a result of this mistake, he got himself into trouble and the Egyptians wouldn’t overlook this act of his and would try to punish him for it. Yet, making the wrong choice doesn’t mean that the act Prophet Musa (pbuh) did was a sin and the disobedience of Allah (swt), all that it means is that Prophet Musa (pbuh) could have made a better choice out of the several options he had.
In the book ‘Uyunu Akhbaril-Ridha, it has been stated that Ma’mun (the ruler at Imam Ridha’s (as) time) asked Imam Ridha (as) this same question. His Excellency answered: “What is meant by “This is on account of Satan's interference”, is the quarrel between the two men, and what is meant by “I wronged myself” is that I placed myself in a situation that I shouldn’t have, and I shouldn’t have entered this city, and what is meant by “forgive me” is “hide me from my enemies” because one of the meanings of ghufran (غفران) which has been mentioned in the verse (which is usually translated as forgiveness) is to hide and conceal something (and doesn’t always mean forgiveness).”
In his book Tanzihul-Anbiya’, Seyyid Murtadha Alamul-Huda has interpreted this verse in two ways:
1- What is meant by wrong (in the verse that quotes Musa (pbuh) saying that he has wronged himself) is that Prophet Musa (pbuh) didn’t do a mustahabb act (which was to postpone the man’s death), instead he acted a bit too fast in help of his follower, thus depriving himself of the reward of the mustahabb act and was upset about this loss. That is why he scolded himself by saying that he had wronged himself.
2- What is meant by the verse that quotes Musa (pbuh) saying: “This is on account of Satan” is the quarrelling of the Egyptian, and Prophet Musa (pbuh) in no way had intended to kill him and all he wanted to do was to help his follower.
In his tafsir of Tibyan, Sheykh Tusi says: “The killing of the Egyptian man wasn’t a bad act and Allah (swt) had ordered Musa (pbuh) to (eventually) kill him, yet it was better for Musa (pbuh) to postpone his killing because of certain reasons, therefore he shouldn’t have rushed in doing so and didn’t make the best choice, and this was the reason for him asking Allah (swt) for forgiveness (note that Sheykh Tusi believes that ghufran here has been used for its usual meaning of forgiveness).
The author of the famous tafsir of Majma’ul-Bayan has also answered this question in the following manner; he says: “The Egyptian was killed for the believer to be freed from him and wasn’t on purpose so it wasn’t a bad act and was actually good.
It has been stated in the book Fat-hul-Ghadir that Musa’s (pbuh) plead for forgiveness was for the wrong choice that he had made and what he meant by saying “forgive me” was that he had wronged himself by killing the Egyptian, because if the Pharaoh was to find out about what had taken place, he surely wouldn’t leave him alone and would surely execute him. What is meant by “forgive me” that Musa (pbuh) says is: “Oh Allah (swt) conceal me so that the Pharaoh doesn’t find me”.
There is one more thing that one can ask and that is that Prophet Musa (pbuh) himself refers to his act as a sin in surah Shu’ara, verse 14 when he says: “And they also have a charge of crime against me”, doesn’t this show that what he did was a sin? The answer is that the Pharaoh was the one who believed what Musa (pbuh) had committed was a crime and sin, but was mistaken and Musa (pbuh) truly wasn’t a sinner.
Conclusion: Sin and disobedience have different levels and degrees. Sometimes one doesn’t go by religious guidelines; such disobedience is surely in conflict with infallibility. Meanwhile, sometimes something isn’t truly considered a sin and is merely a mistake in choosing the best option, yet those who have high levels of spirituality and servitude, who are very sensitive about upsetting their lord even in the least way, consider anything that might upset Him a sin, although they truly haven’t broken any of His rules.
For further information, see indexes:
1- The infallibility of the prophets in the Quran, Question 1069.
2- The infallibility of the prophets according to the Quran, Question 998.
 Mufradat Ragheb and Kitabul-Ayn under the root word عصم.
 Jafar Subhani, Muhadharatun fil-Ilahiyyat, pg. 405.
 وَ دَخَلَ الْمَدینَةَ عَلى حینِ غَفْلَةٍ مِنْ أَهْلِها فَوَجَدَ فیها رَجُلَیْنِ یَقْتَتِلانِ هذا مِنْ شیعَتِهِ وَ هذا مِنْ عَدُوِّهِ فَاسْتَغاثَهُ الَّذی مِنْ شیعَتِهِ عَلَى الَّذی مِنْ عَدُوِّهِ فَوَکَزَهُ مُوسى فَقَضى عَلَیْهِ قالَ هذا مِنْ عَمَلِ الشَّیْطانِ إِنَّهُ عَدُوٌّ مُضِلٌّ مُبینٌ (15) قالَ رَبِّ إِنِّی ظَلَمْتُ نَفْسی فَاغْفِرْ لی فَغَفَرَ لَهُ إِنَّهُ هُوَ الْغَفُورُ الرَّحیمُ (16) Surah Qasas:15-16.
 Makarem Shirazi, Tafsir Nemouneh, vol. 16, pg. 42; Makarem Shirazi, Tafsirul-Bayan, vol.7-8; Sheykh Tusi, Tafsir Tibyan, vol. 2, pg. 391, Tafsir Ithna Ashari, vol.10, pg.94.
 Tafsir Nurul-Thaqalain, vol.4, pg.119; Tafsir Ithna Ashari, vol.10, pg.94.
 Uyunu Akhbaril-Ridha, pg.155, chapter 15; Nurul-Thaqalain, vol.4, pg.119; Al-Mizan, vol.16, pg. 18.
 Quoted from Majma’ul-Bayan.
 Tafsir Tibyan, vol.2, pg.291.
 Fadhl ibn Hasan Tabarsi, Majma’ul-Bayan, vol.7, pg. 164.
 Muhammad ibn Ali Shokani, Tafsir Fathul-Qadir, vol.4, pg.164.