For I say unto you, That except your righteousness shall exceed [the righteousness] of the scribes and Pharisees, ye shall in no case enter into the kingdom of heaven.
Note 10 at Mt 5:20: Jesus' parable of the Pharisee and the publican in Lu 18:9-14 gives us an idea of the outward standard of holiness that the Pharisees observed. That Pharisee did not cheat, steal, or commit adultery. He gave tithes of everything that he possessed and fasted twice each week.
In His Sermon on the Mount, Jesus was not saying that we have to fast more than twice each week to enter into the kingdom of heaven. Rather, He was exposing the religious leaders' superficial self-righteousness, and He began to explain, in this verse through Mt 6:18, that God looks on the heart (1Sa 16:7). The scribes and Pharisees had put all of the emphasis on physical acts of compliance with many laws and traditions, but in their hearts, they were still of their father, the devil (Joh 8:44). They had made the outside clean, but within, they were full of all uncleanness, hypocrisy, and iniquity (Mt 23:25-28).
The Pharisees, like many people today, were ignorant of achieving right standing (righteousness) with God through simply receiving His forgiveness by faith and were trying to earn salvation by their acts. No one can fulfill God's commands (Ro 3:23) but Jesus (Heb 4:15). Therefore, to be righteous, we must put our faith in what He has done for us (Ro 9:31-10:4; 2Co 5:17; Ga 3:11-12, and 5:4-6).