The first step to salvation is acknowledging that we are helpless sinners deserving of hell. If we were anything different, then Jesus need not have had to die on the Cross to take our penalty for sin upon Himself. We don't deserve to be saved, and we are not doing God any favours by receiving Christ as Saviour. There is no merit or goodness in us that would make God want to save us. The Scripture says that all our own righteousness is as filthy rags before God. So there is nothing we can do to save ourselves except to put our trust in Christ crucified.
All throughout the Bible, God wanted Hi people to repent and to return to obedience to His law, so He does not then turn around and hold those who do that in contempt by viewing our righteousness as being filthy rags, but rather the righteous deeds of the saints are like fine white linen (Revelation 19:8).
Our salvation is from sin (Matthew 1:21) and sin is the transgression of God's law (1 John 3:4), so having the experience of living in obedience to it through faith in Jesus is intrinsically the content of his gift of saving us from having the experience of not living in obedience to it. In Titus 2:11-14, our salvation is described as being trained by grace to do what is godly, righteous, and good, and to renounce doing what is ungodly, so we do not earn our salvation as the result of having done those works and we do not do those works as the result of having already been saved, but rather God graciously teaching us to experience those works is itself the content of His gift of saving us from not experiencing those works. Furthermore, in Titus 2:14, Jesus gave himself to redeem us from all lawlessness and to purify for himself a people of his own possession who are zealous for doing good works, so becoming zealous for doing good works in obedience to God's law is the way to put our trust in Christ crucified, which has nothing to do with trying to save ourselves.
Subsequent to being saved, following God's moral law as shown in the Ten Commandments is a labour of love toward God. Jesus summed up the whole law by saying that we love God with all our heart, strength and mind, and love our neighbour as we love ourselves. This is what is involved in following the commandments of Christ. If we were able to love God perfectly, we would be able to keep the commandments perfectly, but we can't, therefore we are unable to love God perfectly. This means that we will always fall short of following the commands of Christ in order to make our righteousness superior to that of the Pharisees, who were absolute legalistic about following the law blamelessly.
Nowhere does the Bible refer to the Ten Commandments as being the moral law, nor does it state that it is moral to disobey everything but the Ten Commandments, nor does it lists which laws are the moral law, nor does it even refer to that as being a subcategory of law. Rather, morality is in regard to what we ought to do and we ought to obey God, so all of God's laws are inherently moral laws. Furthermore all of God's laws are a labor of love toward God, which is why Jesus summed up the whole law as being about how to love God and our neighbor. In Deuteronomy 6:4-7, the way to obey the greatest commandment is by having the Torah on our hearts and by speaking about and teaching it throughout the day.
There is no special significance to us having perfect obedience and if someone does not manage to have perfect obedience, then they can repent and return to obedience through faith. In Matthew 23:23, Jesus said that tithing was something that they ought to be doing while not neglecting weightier matters of the law of justice, mercy, and faith, so the problem was that they were neglecting to express aspects of God's nature that God's law was given as a gift to teach us how to express.
Therefore, the Levitical Law, involving the Ten Commandments, and Jesus' sermon on the mount are there to show us how sinful we are, because the standard expected of us to have our own righteousness before God is higher than what we can achieve. Therefore if our salvation depended on our ability to follow the Law and the sermon on the mount perfectly, then we would be absolutely lost and would perish in hell.
God's law was given as a gift to teach us how to testify about His holiness, righteousness, goodness, and other aspects of His nature, but only reveals our sin by contrast, which is the way to know God, and which is the goal of the law (Romans 10:2-4). Even if someone managed to follow God's perfectly, then they still would not earn their salvation as a wage, so that was never the goal of the law.
But our salvation does not depend on our own righteousness. It depends on Jesus suffering and dying on the Cross to take the penalty for our sin and to bestow His own perfect righteousness on us. Therefore we are saved by God's grace through our faith in Christ alone without anything we can add to it.
God's law was never given as a means of establishing our own righteousness, but as a means of teaching us how to testify about God's righteousness. Our good works don't establish our goodness, but rather they testify about God's goodness, which is why they bring glory to Him (Matthew 5:13-16). Jesus expressed his righteousness by loving in obedience to God's law, so that is the way that we also live when we have been bestowed with his righteousness.
Again, according to Psalms 119:29-30, obedience to God's law is the one and only way to be saved by grace through faith. In Romans 3:21-22, it does not say that the Law and the Prophets testify that the righteousness of God comes through perfect obedience, but rather the one and only way to become righteous that is testified about in the Law and the Prophets is through faith in Jesus.