Gal. 3:10. 'For as many as are of the works of the law are under the curse, for it is written, "Cursed is everyone who does not continue in all things which are written in the book of the law, to do them." But that no one is justified by the law in the sight of God is evident, for, "the just shall live by faith."'
Note that the Holy Spirit does not say, "For as many as are of the law are under the curse." It is those who are 'of the works of the law' who are cursed. That is, those who try to work to gain their salvation are cursed because they can never do it.
But we are still to keep the Ten Commandments, not in order to be saved, but because we are saved, and God's law is written on our hearts (Psalm 40:8; Hebrews 8:10). It is our delight to keep God's righteous moral law and it grieves us when we fail to do so (Romans 22-25).