The big picture is,
God's goal is to build an eternity we call Heaven where humans and angels will live with God happily forever. The three parties must be happy and satisfactory. The completely sin-incompatible God won't be happy to live with sins in such a forever realm.
Law is thus set up to identity who (both angels and humans alike) is qualified to enter Heaven to live with such a sin-incompatible God forever. Law is more or less like a promise saying that, "if you pass the Final Judgment of Law, God will bear with you in eternity no matter what." That's why God's Law is strict in order to stick with such a promise.
The nature of Law works like this. Given a pre-defined period of time, an entity of freewill must not break it. It's an assessment of one's ability to obey. Free will at the end means one is given the ability to oppose God. Law measures one's ability to be obedient without exercising the ability of opposing God, such that God, as well as angels and humans, can live together without an issue. By the hint given in the book of Revelation, 2/3 angels will pass the Final Judgment of Law to enter Heaven.
How about humans? Genesis says that the much more capable and intelligent angelic beings (i.e., the crafty snake) will tempt humans into breaking the Law. Adam and Eve fell due to, or the lack thereof, the two critical factors without which humans won't be able to live with a sin-compatible God in the forever realm. First is the lack of obedience, and second is the lack of faith in God and His words (i.e., the Word of God in a broader sense).
Ever since Adam and Eve sinned under the influence of Satan, Law requires that humans need to be driven out of God's current dwelling realm. Today's earth is outside the realm of God. While any place lying outside of God's dwelling realm will decay to a hell where the most powerful and the most evil will finally rule. This happens to be Satan. That's why Satan is referred to as the god of this world.
Satan turned Earth into a wilderness,
Isaiah 14:17: the man who made the world a wilderness, who overthrew its cities and would not let his captives go home?
In such a wilderness virtually 'ruled' by Satan, humans have no hope to pass the Final Judgment of Law to enter Heaven. Satan and his angels (they are much more capable and intelligent than humans) will make sure that humans are captive and 'would not let his captives go home'. As a result, God either destroy earth as a whole (by Noah's flood), or there must be an alternative provided to get this resolved. Needless the say, the resolution is Jesus Christ. With Jesus' self-sacrifice at some point of humanity, it makes it possible that humans can 'dodge' the Final Judgment of Law. Humans now are provided a series of covenants as the alternative standard for the Final Judgment (of Covenant instead of Law) to come.
While Law is provide a pre-defined period of time for an entity of free will not to break it. a covenant works on a human through his life span, followed by a Final Judgment of Covenant subjective by a fair and just God (who is Jesus Christ our Lord, as God the Son). Under the New Covenant, your life span is for the assessment of your faith as demanded by the Final Judgment of Covenant carried out by Jesus Christ.
Again it's like promise saying that, "if you pass the Final Judgment of Covenant, the completely sin-incompatible God will bear with you in eternity, no matter what!"
That being said. The three-fold meaning of the term Law is well stated by Paul.
Romans 2:13-15
For it is not those who hear the law who are righteous in God’s sight, but it is those who obey the law who will be declared righteous. (Indeed, when Gentiles, who do not have the law, do by nature things required by the law, they are a law for themselves, even though they do not have the law. They show that the requirements of the law are written on their hearts, their consciences also bearing witness, and their thoughts sometimes accusing them and at other times even defending them.)
Firstly, the heavenly Law now can only practically apply to the angels and is no longer demonstratable to humans. With this set of heavenly Law, 2/3 angels will pass the Final Judgment of Law to enter Heaven (as hinted in Rev.). To humans and in front of this set of heavenly Law, it is said that, "no one is righteous not even one." No humans can be deemed righteous in front of the Judgment of Law. Humans are saved through the covenants granted by God's Grace through Jesus Christ.
Secondly, Mosaic Law is a set of laws under the Mosaic covenant. It's covenantal and for God to demonstrate to humans, through His chosen people Israel, what His heavenly Law could mean such that humans can have a grasp on what God's Grace could mean under the New Covenant. The scope of Mosaic covenant (with Mosaic Law) only covers the Jews. Gentiles "do not have the law" as Paul put.
Under this set of Law, Moses will determine who to be accused of,
John 5:45: But do not think I will accuse you before the Father. Your accuser is Moses, on whom your hopes are set.
Thirdly, gentiles are under the Law written in our heart, which is our inner conscience. We gentiles will be judged by this thrid set of Law embedded to our heart, unless we choose to hop over to the New Covenant.
Under this set of Law, Satan is the accuser, his role however is nullified if you choose to come to "the salvation and the power and the kingdom of our God, and the authority of his Messiah."
Revelation 12:10
Then I heard a loud voice in heaven say: “Now have come the salvation and the power and the kingdom of our God, and the authority of his Messiah. For the accuser of our brothers and sisters, who accuses them before our God day and night, has been hurled down.