The Pharisees and the scribes never kept the word of God. Instead, they obeyed Traditions of the Elders which nullified the word of God.
Jesus Christ severely criticized the Pharisees and the scribes for obeying Traditions of the Elders which nullified the word of God (Matthew 15, Mark 7).
That's why Jesus Christ's biggest opponents were the scribes and the Pharisees (Matthew 23, Luke 11).
Apostle Paul called Traditions of the Elders as "Traditions of our fathers" in Galatians 1:14 and Jewish Priest Josephus calls "Traditions of the Elders" as "Tradition of our forefathers."
"What I would now explain is this, that the Pharisees have delivered to the people a great many observances by succession from their fathers, which are not written in the laws of Moses; and for that reason it is that the Sadducees reject them, and say that we are to esteem those observances to be obligatory which are in the written word, but are not to observe what are derived from the tradition of our forefathers." (Antiquities of Jews Book XIII.X.VI).
That's why you see Jesus Christ saying this.
John 5:46-47 (NIV) - "If you believed Moses, you would believe me, for he wrote about me. But since you do not believe what he wrote, how are you going to believe what I say?”
John 7:19 (NIV) - "Has not Moses given you the law? Yet not one of you keeps the law. Why are you trying to kill me?”
We also see Stephen saying how they didn't obey the laws of God.
Acts 7:52-53 (NIV) - "Was there ever a prophet your ancestors did not persecute? They even killed those who predicted the coming of the Righteous One. And now you have betrayed and murdered him— you who have received the law that was given through angels but have not obeyed it.”
Traditions of the Elders (a.k.a Traditions of our forefathers) existed as early as when John Hyrcanus I ruled (135 BC to 104 BC).
Josephus' Antiquities of Jews XIII.XVI.II - "So she (Salome Alexandra) made Hyrcanus high priest, because he was the elder, but much more because he cared not to meddle with politics, and permitted the Pharisees to do every thing; to whom also she ordered the multitude to be obedient. She also restored again those practices which the Pharisees had introduced, according to the traditions of their forefathers, and which her father-in-law, Hyrcanus, had abrogated."
Traditions of the Elders later came to be known as Talmud. This is agreed by Jewish society.
Rabbi Michael Rodkinson - "The Talmud, then, is the written form of that which, in the time of Jesus, was called the Traditions of the Elders, and to which he makes frequent allusions" (Source - The History of the Talmud, Vol. II, page 70, Chapter IX).
The righteousness of the scribes and Pharisees were extremely low due to the fact that they obeyed Traditions of the Elders which nullified the word of God as I mentioned above. So in order to enter into the kingdom of heaven, your righteousness should exceed the righteousness of scribes and Pharisees by obeying the written word of God and believing in Jesus Christ.