Problem: In this text, Jesus urged His disciples to pray in private, saying, “When you pray, go into your room, and when you have shut your door, pray to your Father who is in the secret place.” However, elsewhere the Bible commends praying in public. For example, Daniel prayed with his window open so he could be seen (Dan. 6:10). Solomon offered his great dedicatory prayer for the temple in public (1 Kings 8:22). And Paul urged public prayers “for men everywhere” (1 Tim. 2:8).
Solution: It is not public prayers which Jesus condemned, but ostentatious prayers. He was not opposed to people praying in appropriate public places, but in conspicuous places. It was not the place of prayer so much as the purpose of their prayer that Jesus spoke against, namely, “that they may be seen by men” (Matt. 6:5).
“But thou, when thou prayest, enter into thy closet, and when thou hast shut thy door, pray to thy Father which is in secret; and thy Father which seeth in secret shall reward thee openly.” (Matt 6:6)”