What kind of attitude is required to be right before God? It requires a humility that is able to see, and be completely honest about the true condition of our heart before God - That we are wicked in His sight, That we are ashamed and sorrowful for our rebellion and rejection of Him, That we acknowledge there is nothing we can do to make things right, only by His grace can He restore us to a right relationships.
It is a fact of human nature that we love to compare ourselves with others. The point of this exercise is to exalt ourselves - to create the impression in our own mind that we are superior to others. This habit of human existence is motivated by our pride, our need to be "somebody" or to "make something of our self." In order for this to work, we need to find people who are less than us, and who we can look down on in some way or another. We create categories and classes of people who are not as good as us for any number of reasons, and then we hold ourselves up against this "worthless" class of people and proclaim how wonderful we are!