Allah T'ala says in the Holy Quran:
قُل لاَّ يَسْتَوِي الْخَبِيثُ وَالطَّيِّبُ وَلَوْ أَعْجَبَكَ كَثْرَةُ الْخَبِيثِ فَاتَّقُواْ اللّهَ يَا أُوْلِي الأَلْبَابِ لَعَلَّكُمْ تُفْلِحُونَ
(5:100) (O Messenger!) Say to them: "The bad things and the good things are not equal, even though the abundance of the bad things might make you pleased with them. Men of understanding, beware of disobeying Allah; then maybe you will attain true success.'
(2:177) It is no virtue that you turn your faces towards the east or the west, but virtue is that one should sincerely believe in Allah and the Last Day and the Angels and the Book and the Prophets and, out of His love, spend of one’s choice wealth for relatives and orphans, for the needy and the wayfarer, for beggars and for the ransom of slaves, and establish the Salat and pay the Zakat. And the virtuous are those who keep their pledges when they make them and show fortitude in hardships and adversity and in the struggle between the Truth and falsehood; such are the truthful people and such are the pious.
Turning one’s face towards the east or the west is mentioned here only by way of illustration. The actual purpose of the verse is to emphasize that the observance of certain outward religious rites, the performance of certain formal religious acts out of conformism, and the manifestation of certain familiar forms of piety do not constitute that essential righteousness which alone carries weight with God and earns His recognition and approval.
It is not piety, that you turn your faces, in prayer, to the East and to the West. This was revealed in response to the claim made by the Jews and the Christians to this effect. True piety, that is, the pious person (al-birr, is also read al-barr, in the sense of al-bārr [‘the dutiful person’]) is [that of] the one who believes in God and the Last Day and the angels and the Book, that is, the scriptures, and the prophets, and who gives of his substance, however, despite [it being], cherished, by him, to kinsmen and orphans and the needy and the traveller and beggars, and for, the setting free of, slaves, both the captive and the one to be manumitted by contract; and who observes prayer and pays the alms, that are obligatory, and what was [given] before [alms were made obligatory], in the way of charity; and those who fulfil their covenant when they have engaged in a covenant, with God or with others, those who endure with fortitude (al-sābirīna is the accusative of laudation) misfortune (al-ba’sā’ is abject poverty), hardship, illness, and peril, at the height of a battle in the way of God; these, described in the way mentioned, are the ones who are truthful, in their faith and in their claims to piety, and these are the ones who are fearful, of God.