Allah says...
Allah says: Attend constantly to prayers and to the middle prayer and stand up truly obedient to Allah. Qur'an, 2:238 Surely Allah loves those who fight in His way in ranks as if they were a firm and compact wall. Qur'an, 61:4 The Sura in which this verse is, has been called ‘the sura of as-Saff or rank’, since rank or order is very important near Allah.
Perhaps, the problem of the Shia concerning the congregational prayer where some lack of seriousness and indifference is found is because throughout the history they have faced severe conditions. It was very difficult for them to offer congregational prayers behind Sunni imams who changed the rulings of prayer and used to abuse Imam Ali (a.s.) and the Ahlul Bayt (a.s.) in their prayers.
On the other hand, they avoided offering the prayer in a special congregation, because this meant that they would be accused of being “ rawafidh , rejecters” and this would lead to doing away with them. Therefore, they often offered congregational prayers with the Sunni out of taqiyya [^5], then immediately left the place after the end of the prayer. Most of them might offer the prayer again when they would be in their houses.
We may conclude from this too that the dissenters of the Ahlul Bayt (a.s.) have called themselves “ the people of the Sunna and congregation ” because the majority of Muslims followed them and offered the prayer in their congregation, whereas the Shia offered their prayers behind their own imam, and thus they were minority, like a white spot in a black dress, after their appearing as a special sect.
After their having appeared as a special Islamic school adhering to the jurisprudence of the Ahlul Bayt (a.s.), the Shia limited themselves to strictly pray behind a just, knowledgeable, abstinent imam in accordance with the religious texts in this regard on one hand and as a reaction to the Sunni, who were permitted to pray behind any good or corrupted man on the other hand.
This has also affected the congregational prayer of the Shia - so you see that when one of them comes into a mosque and does not know the imam of the congregational prayer, he offers the prayer individually in one of the mosque’s corners. It is because he does not know the imam, so he does not trust him (as to be a just person or not).
On the other side, the Sunni are wasteful in this concern in that they permit the prayer behind anyone whether good or bad, pious or impious, abstinent or corrupted.