Jared Wilson says that the answer is simple: By actually becoming holy, not just thinking we are.
He goes on to say:
Holiness and holier-than-thou-ness aren’t parallel phenomena. They run on different tracks. If someone is growing in arrogance, pride, and self-righteousness, by definition they are not growing in holiness.
The problem arises in equating holiness with religious behavior. Holy people do obey God, of course. But the character of holiness, in which the Spirit does his progressive sanctifying work in our hearts (and therefore in our thoughts, speech, and actions), produces qualities of humility, gentleness, kindness, and self-control. Any arrogant fool can abstain from certain sins or give to charity and what-not. The Pharisees certainly did that, and all our legalistic contemporaries do too. But that is not real holiness. That is moralistic separatism or some such thing.
Therefore, it is impossible to become both holy and holier-than-thou. To grow in one, is to atrophy in the other.
The bad news is that God—who said, “Be holy for I am holy”—knows when your actions are all behaviour modification without heart change (Jeremiah 17:10). More bad news is that outward actions, in and of themselves, don’t actually help (Colossians 2:23).