Putting the publican and the Pharisee in context
The parable of the Pharisee and the publican (tax collector) is a powerful story of why humility is far preferable to self-righteousness, but I do not think we realize just how radical and offensive that parable was at the time Jesus told it.
Publicans were hated in Judea, for several reasons. First, the publicans were Jews who were betraying their people by collecting taxes for the hated Roman Empire, which was oppressing the Jewish people. Not only were they traitors who were collaborating with an occupying power, but they would often abuse their authority to steal from their fellow Jews by collecting more taxes than were due and keeping the difference to enrich themselves.
For Jesus to say this hated tax collector, traitor, and criminal was more justified than the Pharisees would have been scandalous to the people He was teaching. This would be like how a black person working for the Ku Klux Klan would be seen by other blacks, but it is more than just a racial identity. The Jews were also defined by their nation, and the Romans were a pagan empire that worshiped and served false "gods." The combination of ethnic, nationalistic and religious factors would have made these traitors the lowest of the low.
And make no mistake about it: The Pharisee, self-righteous and proud though he was, was absolutely more righteous than the publican. Everyone at the time would have understood that. So for Jesus to say that a traitor who lived a wicked life was more justified before God than a Pharisee was an incredibly radical position that puts the focus directly on God and His infinite grace and mercy rather than human works.
We today often do not have the context of the culture when the Scriptures were written. Knowing that context makes the text even more powerful than it already is.