Romans 7:1-4 Or do you not know, brothers[a]for I am speaking to those who know the lawthat the law is binding on a person only as long as he lives? 2 For a married woman is bound by law to her husband while he lives, but if her husband dies she is released from the law of marriage. 3 Accordingly, she will be called an adulteress if she lives with another man while her husband is alive. But if her husband dies, she is free from that law, and if she marries another man she is not an adulteress.
Paul was speaking to those Jews and Gentiles who knew the law, not to tell them their knowledge of how to keep the law was of no value, but rather he was making an example from the law that they would understand. If Paul were making a metaphor where everything in it represented something else, then it would not make sense. Are we represented by the wife? No, we are dying to the law and it is the husband who is dying. Are we represented by the husband? No, it is the wife who is free to come under a new master.
Furthermore, the wife's husband died, she would not be freed from any of the other laws, but just that aspect of the law that would penalize her if she were to live with another man while her husband was still alive. If after her husband died and she married another man, she would be bound again to that same law. So the wife was not dying to the marriage law, but the penalty that it would require for breaking it. Paul was building to his conclusion in Romans 8:1 that there therefore is no condemnation for those who are in Messiah. This still exists God's commands for how to practice righteousness and it is always important for God's people to practice that.
Indeed, the Gospel is about righteousness by faith apart from the law, which Paul talked about in Romans 3:21-30, but he added verse 31 to make sure that no one misunderstood him and thought that the law played no part in the Gospel. Being declared righteous is just the beginning of the Christian walk, the Good News is also that we are set free from sin to become slaves of obedience, leading to righteousness and sanctification. Just like Moses was declared righteous by faith before he was given the law at Sinai, he needed to be given it so that those who God declared righteous would know how to practice righteousness in obedience to Him.
Indeed, the law is how we know what sin is (Romans 7:7), so acting unlawfully is sin and Paul said in Romans 6:15 that being under grace didn't mean we were to sin. Christians are citizen of the commonwealth of Israel by faith in Messiah, so as God people who should follow the law that God gave to His people to obey.
And we are part of Israel by faith in Messiah, so we should keep those commands forever.
Indeed, why would God's people think it was unimportant to obey His instructions?