Suuratul – Baqarah Verse 177.
لَّيْسَ ٱلْبِرَّ أَن تُوَلُّوا۟ وُجُوهَكُمْ قِبَلَ ٱلْمَشْرِقِ وَٱلْمَغْرِبِ وَلَـٰكِنَّ ٱلْبِرَّ مَنْ ءَامَنَ بِٱللَّـهِ وَٱلْيَوْمِ ٱلْـَٔاخِرِ وَٱلْمَلَـٰٓئِكَةِ وَٱلْكِتَـٰبِ وَٱلنَّبِيِّـۧنَ
وَءَاتَى ٱلْمَالَ عَلَىٰ حُبِّهِۦ ذَوِى ٱلْقُرْبَىٰ وَٱلْيَتَـٰمَىٰ وَٱلْمَسَـٰكِينَ وَٱبْنَ ٱلسَّبِيلِ وَٱلسَّآئِلِينَ وَفِى ٱلرِّقَابِ وَأَقَامَ ٱلصَّلَوٰةَ وَءَاتَى ٱلزَّكَوٰةَ
وَٱلْمُوفُونَ بِعَهْدِهِمْ إِذَا عَـٰهَدُوا۟ ۖ وَٱلصَّـٰبِرِينَ فِى ٱلْبَأْسَآءِ وَٱلضَّرَّآءِ وَحِينَ ٱلْبَأْسِ ۗأُو۟لَـٰٓئِكَ ٱلَّذِينَ صَدَقُوا۟ ۖ وَأُو۟لَـٰٓئِكَ هُمُ ٱلْمُتَّقُونَ ﴿١٧٧
177. It is not Al-Birr (piety, righteousness) that you turn your faces towards east and (or) west (in prayers); but Al-Birr is (the quality of) the one who believes in Allah, the Last Day, the Angels, the Book, the Prophets and gives his wealth, in spite of love for it, to the kinsfolk, to the orphans, and to Al-Masakin (the poor), and to the wayfarer, and to those who ask, and to set slaves free, performs As-Salat, and gives the Zakat, and who fulfill their covenant when they make it, and who are As-Sabirin (the patient ones, etc.) in extreme poverty and ailment and at the time of fighting. Such are the people of the truth and they are Al-Muttaqun.
Tafsir Ibn Kathir Volume 1, Page 178.
This Ayah contains many great wisdoms, encompassing rulings and correct beliefs. As for the explanation of this Ayah, Allah first commanded the believers to face Bayt Al-Maqdis, and then to face the Ka`bah during the prayer. This change was difficult for some of the People of the Book, and even for some Muslims. Then Allah sent revelation which clarified the wisdom behind this command, that is, obedience to Allah, adhering to His commands, facing wherever He commands facing, and implementing whatever He legislates, that is the objective. This is Birr, Taqwa and complete faith. Facing the east or the west does not necessitate righteousness or obedience, unless it is legislated by Allah. This is why Allah said:
﴿لَّيْسَ الْبِرَّ أَن تُوَلُّواْ وُجُوهَكُمْ قِبَلَ الْمَشْرِقِ وَالْمَغْرِبِ وَلَـكِنَّ الْبِرَّ مَنْ ءَامَنَ بِاللَّهِ وَالْيَوْمِ الاٌّخِرِ﴾
(It is not Birr that you turn your faces towards east and (or) west (in prayers); but Birr is the one who believes in Allah and the Last Day,)
Similarly, Allah said about the sacrifices:
﴿لَن يَنَالَ اللَّهَ لُحُومُهَا وَلاَ دِمَآؤُهَا وَلَـكِن يَنَالُهُ التَّقْوَى مِنكُمْ﴾
(It is neither their meat nor their blood that reaches Allah, but it is the piety from you that reaches Him.) (22:37)
Abu Al-`Aliyah said, “The Jews used to face the west for their Qiblah, while the Christians used to face the east for their Qiblah. So Allah said:
﴿لَّيْسَ الْبِرَّ أَن تُوَلُّواْ وُجُوهَكُمْ قِبَلَ الْمَشْرِقِ وَالْمَغْرِبِ﴾
(It is not Birr that you turn your faces towards east and (or) west (in prayers)) (2: 177) meaning, “this is faith, and its essence requires implementation.” Similar was reported from Al-Hasan and Ar-Rabi` bin Anas. Ath-Thawri recited:
﴿وَلَـكِنَّ الْبِرَّ مَنْ ءَامَنَ بِاللَّهِ﴾
(but Birr is the one who believes in Allah,) and said that what follows are the types of Birr. He has said the truth. Certainly, those who acquire the qualities mentioned in the Ayah will have indeed embraced all aspects of Islam and implemented all types of righteousness; believing in Allah, that He is the only God worthy of worship, and believing in the angels the emissaries between Allah and His Messengers.