Yes they contradict but this is where rightly dividing comes in....both are true but pertain to which dispensation is in viewthis contradicts Jesus and the rest of the bible, remember in hebrews paul spoke about the new covenant by quoting isaish 31:31-33? he alsi sais the law was just and good?
Paul said the law was good but there are things we need to understand:
the law had to be used lawfully
[1Ti 1:8-9 KJV] 8 But we know that the law [is] good, if a man use it lawfully; 9 Knowing this, that the law is not made for a righteous man, but for the lawless and disobedient, for the ungodly and for sinners, for unholy and profane, for murderers of fathers and murderers of mothers, for manslayers,
Not made for the righteous....according to Paul those who believe his gospel are righteous (Rom 4:5 5:1 5:17)
The law does include the ten commandments....the ten are not separate...look at the following verses
[Rom 2:18, 20-23 KJV] 18 And knowest [his] will, and approvest the things that are more excellent, being instructed out of the law; ... 20 An instructor of the foolish, a teacher of babes, which hast the form of knowledge and of the truth in the law. 21 Thou therefore which teachest another, teachest thou not thyself? thou that preachest a man should not steal, dost thou steal? 22 Thou that sayest a man should not commit adultery, dost thou commit adultery? thou that abhorrest idols, dost thou commit sacrilege? 23 Thou that makest thy boast of the law, through breaking the law dishonourest thou God?
v18 v20 speaks of the law....it quotes the ten....v21 do not steal...v22 do not commit adultery and make no carved images.....the ten is also the law
[Rom 3:20 KJV] 20 Therefore by the deeds of the law there shall no flesh be justified in his sight: for by the law [is] the knowledge of sin.
You can't be justified, declared righteous, by keeping the ten/law