In another parable, Jesus spoke to those who were proud, haughty and thought of themselves as better than others. It was a Jewish practice to pray at mid morning, mid afternoon or any other time they felt the need. If they were near the temple, they went inside or if they were too far away, they looked toward the temple.
The Pharisee in this parable was self-righteous and placed himself uppermost in his prayer instead of worshipping God. He confessed his goodness instead of his sins.
God hates pride and loves humility. The publican (tax collector) was justified because he humbled himself, recognized and confessed his sins and begged for mercy.