One ‘why’ of the Law: for Israel to be a light to the nations around it. No one else has a god as close as this God is to His people: one who lives amongst them and is always there when they call out to Him.
Obey God, and everyone will think you’re so wise:
Deuteronomy 4:5-7 Look, I now teach you these decrees and regulations just as the Lord my God commanded me, so that you may obey them in the land you are about to enter and occupy. Obey them completely, and you will display your wisdom and intelligence among the surrounding nations. When they hear all these decrees, they will exclaim, ‘How wise and prudent are the people of this great nation!’