There were more than a few rules. The first set of rules focused on sexual morality, urging the Israelites not to behave like the Egyptians or the Canaanites:
18:27-28 All these detestable activities are practiced by the people of the land where I am taking you, and this is how the land has become defiled. So do not defile the land and give it a reason to vomit you out, as it will vomit out the people who live there now.
To use a modern-day cliche, marriage was between a man and a woman. Anything was was ‘detestable’.
Child sacrifice to idols was also banned as detestable to God (Deuteronomy 12:31). It was already implied by God’s claim on the firstborn, and His limiting of sacrifice to a select group of the best animals.
Breaking the rules would see the Israelites removed from Canaan, just as they would drive out the Canaanites; the Israelites’ special position with God wouldn’t save them if they couldn’t honour him. Keeping the rules would find favour:
18:5 If you obey my decrees and my regulations, you will find life through them. I am the Lord.
The reason, as usual, was:
19:2 … You must be holy because I, the Lord your God, am holy.
A second set of rules was an expansion of the ten commandments, with some extra rules about peace offerings, agricultural practices and other matters. Some rules went to the heart (‘do not nurse hatred in your heart’) and not just the outward appearance.
These rules also came with a repeat of His command that:
20:22-24 You must keep all my decrees and regulations by putting them into practice; otherwise the land to which I am bringing you as your new home will vomit you out. Do not live according to the customs of the people I am driving out before you. It is because they do these shameful things that I detest them. But I have promised you, ‘You will possess their land because I will give it to you as your possession—a land flowing with milk and honey.’ I am the Lord your God, who has set you apart from all other people.
20:26 You must be holy because I, the Lord, am holy. I have set you apart from all other people to be my very own.
So although these might appear random to us, the rules that God has set down for the Israelites were about setting them apart from the other peoples in the region. God had rescued them from Egypt, was taking them to Canaan, and wanted them to be holy and devoted to Him.