Because the OT laws are old covenant laws. Christians are under a new covenant.
A covenant is an agreement. This agreement, or covenant, which God made with Israel was based on old covenant law.
There is a difference between a set of laws for how to have a holy, righteous, and good conduct and a covenant agreement to have such a conduct. God is holy, righteous, and good from the beginning, so the way to have such a conduct existed in the beginning and exists independently of any covenant agreement to have such a conduct.
*Then the LORD said to Moses, "Write down these words, for in accordance with these words I have made a covenant with you and with Israel." ...And he wrote on the tablets the words of the covenant — the Ten Commandments.* -- (Ex 34:27-28).
You will notice that the old covenant was founded on the Ten Commandments written on stone tablets.
You will also notice that the old covenant was made with Israel and not with gentiles.
The New Covenant was also only made with the house of Israel and the house of Judah (Jeremiah 31:31), not with Gentiles, which is why Gentiles are grafted into Israel, and why they should follow the commands given to Israel.
The law and the prophets in these verses are not referring to the Ten Commandments specifically, they are instead referring to the Old Testament books written by Moses and the prophets. These books prophesied, or predicted, the things the Messiah was expected to do during His ministry. Christ did fulfill, or accomplish, all that He was prophesied to do during His ministry. This fulfillment was completed at His death on the cross.
*So when Jesus had received the sour wine, He said, "It is finished!" And bowing His head, He gave up His spirit.* -- (John 19:30).
Now that the law and the prophets are fulfilled by Christ we are no longer under the old covenant law.
To fulfill the law is a term that is found in Jewish literature that is used to mean to interpret the law in a way that fills it up with meaning or to demonstrate how it should correctly be obeyed. Every Sabbath a rabbi in a synagogue would take a Torah scroll to Moses' seat and fulfill the law by interpreting it and teaching how it should be understood. Jesus fulfilled the law both by teaching how it should be obeyed, such in the rest of Matthew 5, and by demonstrating a perfectly sinless example for us to follow. Everyone who since Moses who has loved their neighbor as themselves has fulfilled the law (Galatians 5:14), so it was not a once in for all thing that Jesus did, nor did it have the same meaning as abolishing the law, because Jesus said he came to fulfill the law in contrast with abolishing it.
When Jesus said that it was finished, he was referring to his redemptive work on the cross, not the law. He said not the least part would disappear from the law until heaven and earth passed away and all is accomplished, both of which haven't happened yet and are referring to end times. Heaven and earth are still here and his second coming and all that comes with it has not yet been accomplished. If Jesus did away with the Law and the Prophets, then he also did away with the prophecies concerning his second coming.
*God made you alive with Christ. He forgave us all our sins, having canceled the written code, with its regulations, that was against us and that stood opposed to us; He took it away, nailing it to the cross.*
What was nailed to crosses was the violations of the law that the person had committed not the law itself. In other words, they didn't have to legislate new laws every time someone was crucified. Our violations of God's law were nailed to Jesus' cross, so he died for the penalty of our sins and set us free from sin so that we would be free to not transgress God's law. Our salvation is from sin, and sin is the transgression of God's law (1 John 3:4), so our salvation is from transgressing God's law.
*For He Himself is our peace, who has made the two
(Jew and gentile) one and has destroyed the barrier, the dividing wall of hostility, by abolishing in His flesh the law with its commandments and regulations.* -- (Eph 2:14-15).
God's law is his instructions for how to do every good work (2 Timothy 3:16-17), and Paul just got finished saying that we are new creations in Christ for the purpose of doing good works (Ephesians 2:8-10), so it would make no sense to say just a few verses later that Christ did away with his instructions for how to do good works. Rather, what is being referred to in this verse are the man-made laws, such as mentioned in Acts 10:28 that forbade Jews from visiting or associating with Gentiles and possible the dividing wall in the Temple that prevent Jews and Gentiles from worshipping together. A theme throughout the Bible is that we must obey God rather than man, so we must be careful not to mistake something that is speaking against obeying man-made laws as speaking against obeying God's law.
Christ has abolished on the cross the old covenant law founded on the Ten Commandments. We are now under a new covenant law that is founded on the commands of the Spirit.
We are indeed under a new covenant, but God's holiness, righteousness, and goodness remained the same and the way to have such a conduct also remained the same, and we are told to have such a conduct (1 Peter 1:14-16, 1 John 3:10), which involves following God's instructions in His law for how to do that. The Spirit is not in disagreement with the Father about what conduct we should have, but rather the role of the Spirit is to lead us in obedience to God's law (Ezekiel 36:26-27).
(God) has made us competent as ministers of a new covenant — not of the letter but of the Spirit; for the letter kills, but the Spirit gives life. Now if the ministry that brought death, which was engraved in letters on stone, came with glory...will not the ministry of the Spirit be even more glorious?* -- (2 Cor 3:6-9).
If the law did not bring death for transgressing it, then it would not be holy, righteous, and good, but that is a reason to follow the law, not a reason to stop following it.