The question is imprecise: we may not pray for non-Christians in church; we may pray for unbelievers who were baptized, though. Let me explain. It is not exactly forbidden to pray for non-Christians; instead, it is simply meaningless. The Baptism is the door to the Church of Christ, and therefore everything that is performed in the Church is solely for those who belong to it. Consequently, if an individual isn’t baptized, then he or she has nothing to do with the Church, and therefore it’d be futile to pray for him or her. True, we may pray for those people who have not yet entered the Church for some reason in private at our homes. We may ask the Lord to soften their hearts and let them be enlightened by the Sacrament of Baptism.
As far as unbelievers are concerned, this is what we can say: if they are baptized but do not want to live like good Orthodox Christians, that is, to follow God’s commandments, go to church, and pray to God, then we should redouble our prayers to ask the Lord to instruct them and bring them back to the path of truth.
The same holds true also for the dead who, in spite of having been baptized, had not gone to church. Prayer brings the two worlds — that of the living and that of the dead — together. The Church Tradition names these two worlds the Church Triumphant and the Church Militant, and it is prayer that serves as the link between them.
Possibly, the most vivid evidence of how important prayer for the deceased really is, can be found in the Old Testament (Second Book of Maccabees). After one of the battles with Gentiles, the Jews came to bury their dead soldiers. They found under the coats of the slain some of the donaries of the idols. Due to the fact that law forbade all idols, even war trophies, all plainly saw, that for this cause they were slain. All Jews betook themselves to prayers, they besought [God], that the sin which had been committed might be forgotten. Judas, the leader of the Jewish nation, sent a special donation to Jerusalem for an offering to be sacrificed for the sins of the dead. The Scripture characterizes his actions as thinking well and religiously concerning the resurrection, i.e., hoping that the Lord would forgive his compatriots on the Doomsday. And because he considered that they who had fallen asleep with godliness, had great grace laid up for them. It is therefore a holy and wholesome thought to pray for the dead, that they may be loosed from sins. (2 Maccabees 12:39–45).
That is why our prayer for unbelievers, especially those who are already dead, is not just legitimate but is even deemed essential for their souls.
Translated by The Catalog of Good Deeds