Pharisees in Jesus' time enjoyed similar respect with the common people. Pharisees were religious teachers and textbook examples of conventional morality. They usually did what the one in today's gospel said he did. They kept the law. The Pharisee in today's reading was probably right; chances are he wasn't like most people.
Generally, Pharisees were not greedy, dishonest, or adulterers. Or as their exemplar in Luke put it, he was not like the tax collector alongside him in the Temple. Pharisees gave tithes on all they possessed - to help with Temple upkeep.
On the other hand, tax collectors in Jesus' day were notorious crooks. Like pimps, they were usually despised. Tax collectors were typically dishonest and greedy. They were adulterers too. They took advantage of their power by extorting widows unable to pay in money into paying in kind.
In other words, the Pharisee's prayer was correct on all counts.
But we might ask, what about the tax collector's prayer: "O God, be merciful to me, a sinner?" A beautiful prayer, no?
Don't be so quick to say "yes."
Notice that this tax collector doesn't repent. He doesn't say, like the tax collector Zacchaeus in Luke's very next chapter, "Look, half of my possessions, Lord, I will give to the poor; and if I have defrauded anyone of anything, I will pay back four times as much (LK 19:8). There is no sign of repentance or of willingness to change his profession on the part of this particular crook.
And yet Jesus concludes his parable by saying: "I tell you, the latter (i.e. the tax collector) went home justified, not the former. . ." Why?
I think the rest of today's liturgy of the word supplies an answer. Each reading is about God's partiality towards the poor, oppressed, orphans, widows and the lowly - those who need God's special protection, because the culture at large tends to write them off or ignore them. Typically, they're the ones conventionality classifies as deviant. The Jewish morality of Jesus time called them all "unclean."
However, all of them - even the worst - were especially dear to Jesus' heart. And this not because they were "virtuous," but simply because of their social location. Elsewhere, Jesus specifically includes tax collectors (and prostitutes) in that group. In MT 21: 38-42, he tells the Pharisees, "Prostitutes and tax collectors will enter God's Kingdom before you religious professionals."
But why would a good person like the Pharisee be excluded from God's Kingdom? Does God somehow bar his entry? I don't think so. God's Kingdom is for everyone.
Rather it was because men like the Pharisee in the temple don't really want to enter that place of GREAT REVERSAL, where the first are last, the rich are poor, the poor are rich, and where (as I said) prostitutes and tax collectors are rewarded.
The Pharisee excludes himself! In fact, the temple's holy people wanted nothing to do with the people they considered "unclean." In other words, it was impossible for Pharisees and the Temple Establishment to conceive of a Kingdom open to the unclean. And even if there was such a Kingdom, these purists didn't want to be there.
Let's put that in terms we can understand in our culture.
Usually rich white people don't want to live next door to poor people or in the same neighborhood with people of color - especially if those in question aren't rich like them.
Imagine God's Kingdom in terms of the ghetto, the barrio or favela. Rich white people don't want to be there.