Verse 177 of Surah Al-Baqarah describes righteousness and the righteous and presents the criteria of being righteous, including faith in God, the Hereafter, angels and divine books as well as Infaq (disbursement), saying prayers, paying Zakat (almsgiving), Wafa bil-Ahd (keeping one's promise) and maintaining Taqwa (God-fearing).
This verse says, “Righteousness is not whether you face towards the east or the west. But righteousness is to believe in Allah and the Last Day, in the angels and the Book, and the Prophets, and to give wealth however cherished, to kinsmen, to the orphans, to the needy, to the destitute traveler, and to the beggars, and to ransom the slave; who establish their prayers and pay the obligatory charity; who are true to their promise when they have promised. Who are patient in misfortune and hardship and during the time of courage. Such are the truthful; such are the cautious.”
To understand the first part of this verse, learning the view of Sheikh Tabarsi (12th century Shia scholar) would be interesting. He says when the Qibla (direction toward which Muslims say prayers) changed from Al-Quds to Holy Ka’aba in Mecca, disputes arose among Muslims, Jews and Christians. The Jews said it would be better to pray toward the west whereas Christians said prayer should be said while facing the east. This verse was revealed to stresses that these issues are marginal and what matters is righteousness and doing good deeds.
According to this verse, facing the east or the west is not righteousness, but having faith in God, the Hereafter, angels and divine books is. Righteousness is in helping one’s relatives, giving alms to orphans, the destitute and others in needs and helping to free slaves. Elsewhere in this verse, saying prayers, paying Zakat, keeping one’s promise and patience in the face of hardships are also mentioned as criteria of righteousness.
In many Quran exegeses, there has been a Hadith from the Holy Prophet (PBUH) about this verse. The Prophet (PBUH) said anyone who acts upon this verse, his or her faith would be perfected. Alllameh Tabatabaei believes that while acting upon what this verse says is difficult, the verse is not for messengers of God only but also for the Infallible (AS) and the Ulil Albab. The Ulil Albab are the people of intellect and wisdom who have insight.