The reason of revelation: Ibn Al-Munther narrated that Ibn Abbas (may Allah be pleased with him) said about this verse that: It was revealed because of the hypocrites, who used to pray, only to be seen, in the presence of the believers, but when the believers were absent they used to leave the prayer, additionally, they used to withhold them borrowing.
فَوَيْلٌ (woe): Indicates the disgrace, torture and destruction.
This is a threat directed to those who are considered of those who pray and believe sincerely in Allah (swt), while, in fact, they perform the worship deeds and rituals apparently; their hearts do not have any submission or faith or obedience. This condition is explained clearly in the noble Hadith which was narrated by Abo Hurairah (may Allah be pleased with him) that:
“A man entered the mosque and started praying Then (after finishing the prayer) the man came to the Prophet (saws) and greeted him. The Prophet (saws) said to him, “Go back and pray, for you have not prayed. The man went back, and having prayed, he came and greeted the Prophet. The Prophet (saws) after returning his greetings said, “Go back and pray, for you did not pray (repeated it three times)”.
Hence, prayer is not established by just outer acts, rather, it is the act of heart too. In this verse Allah (swt) is threatening those who perform the prayer while ignoring its essence. This is because the prayer is the pillar of faith, whoever establishes it, he, as if, establishes the religion, and whoever leaves it, he, as if, destroys the religion.
 Sahih Al-Bukhari, Book of description of prayer, hadith No. 724.