What is the meaning of Matthew 6:5-6?

5 And when thou prayest, thou shalt not be as the hypocrites are: for they love to pray standing in the synagogues and in the corners of the streets, that they may be seen of men. Verily I say unto you, They have their reward. 6 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. (Matthew 6:5-6 KJV)

William Burkitt’s Commentary

Here our Saviour warns his disciples against the same Pharisaical hypocrisy in praying, which he had before reproved in almsgiving. It was lawful to pray in the synagogues, and to pray standing, and that before men; but to do this upon design to be applauded by men, is condemned by Christ. Our business in prayer lies with God; we are not to concern ourselves how men like our performances; it is sufficient if God doth approve and will accept them. To cure the foregoing vanity, Christ directs to secret prayer, in our closets, where God is the witness, and will be the rewarder of our sincerity.

Note, That secret prayer is a commanded and encouraged duty, and when in sincerity performed, shall be attended with a public and glorious reward; Pray to thy Father which is in secret, &c.