You have neglected to include a very important qualifying verse in your question.
Matthew 5:17 "Do not think that I came to destroy the Law or the Prophets. I did not come to destroy but to fulfill.
The Lord Jesus cam to fulfill certain commands given in the law which were "types and shadows" of what God was going to do in the future.
For instance, the sacrifice of a "spotless lamb" to atone for sins was looking ahead or foreshadowing what God was going to do when the Lord Jesus came down from Heaven, lived a sin free or "spotless" life, and laid His life down on a cross as the ultimate sacrifice for all sins for all time.
Hebrews 10:1 For the law, having a shadow of the good things to come, and not the very image of the things, can never with these same sacrifices, which they offer continually year by year, make those who approach perfect.
Hebrews 10:11 And every priest stands ministering daily and offering repeatedly the same sacrifices, which can never take away sins. 12 But this Man (Jesus), after He had offered one sacrifice for sins forever, sat down at the right hand of God, 13 from that time waiting till His enemies are made His footstool. 14 For by one offering He has perfected forever those who are being sanctified.
So this is an example of a law that has been fulfilled. God no longer requires believers to engage in animal sacrifices which were meant to picture the need for an innocent to die for the guilty if the guilty were to be acquitted of their sins.
In the same manner there were "holiness" laws and "ceremonial" laws which were pointing ahead to what God was going to do and so they have been fulfilled and there is no longer any need for them.
Colossians 2:13 And you, being dead in your trespasses and the uncircumcision of your flesh, He has made alive together with Him, having forgiven you all trespasses, 14 having wiped out the handwriting of requirements that was against us, which was contrary to us. And He has taken it out of the way, having nailed it to the cross. 15 Having disarmed principalities and powers, He made a public spectacle of them, triumphing over them in it. 16 So let no one judge you in food or in drink, or regarding a festival or a new moon or sabbaths, 17 which are a shadow of things to come, but the substance is of Christ.
God's moral laws are still in full effect because they represent His unchanging character and His will for how we who have been created in His image are to behave like our Father in Heaven would have us to behave.
Ephesians 5:1 Therefore be imitators of God as dear children. 2 And walk in love, as Christ also has loved us and given Himself for us, an offering and a sacrifice to God for a sweet-smelling aroma. 3 But fornication and all uncleanness or covetousness, let it not even be named among you, as is fitting for saints; 4 neither filthiness, nor foolish talking, nor coarse jesting, which are not fitting, but rather giving of thanks.
5 For this you know, that no fornicator, unclean person, nor covetous man, who is an idolater, has any inheritance in the kingdom of Christ and God. 6 Let no one deceive you with empty words, for because of these things the wrath of God comes upon the sons of disobedience. 7 Therefore do not be partakers with them.
1 Corinthians 6:9 Do you not know that the unrighteous will not inherit the kingdom of God? Do not be deceived. Neither fornicators, nor idolaters, nor adulterers, nor homosexuals, nor sodomites, 10 nor thieves, nor covetous, nor drunkards, nor revilers, nor extortioners will inherit the kingdom of God. 11 And such were some of you. But you were washed, but you were sanctified, but you were justified in the name of the Lord Jesus and by the Spirit of our God.
Romans 13:8 Owe no one anything except to love one another, for he who loves another has fulfilled the law. 9 For the commandments, "YOU SHALL NOT COMMIT ADULTERY," "YOU SHALL NOT MURDER," "YOU SHALL NOT STEAL," "YOU SHALL NOT BEAR FALSE WITNESS," "YOU SHALL NOT COVET," and if there is any other commandment, are all summed up in this saying, namely, "YOU SHALL LOVE YOUR NEIGHBOR AS YOURSELF." 10 Love does no harm to a neighbor; therefore love is the fulfillment of the law.