G-d gave the first six commandments to Adam and Hava (Eve), the first human beings.
These commandments were repeated to Noah, and a seventh commandment was added, when, after the Flood, G-d established the Covenant of the Rainbow with Noah and all of the world’s creatures. This covenant is not dependent on mankind’s observance of these Seven Laws of Noah. Rather, the Noahide Code established the context and the eventual goal for a renewed world in which this covenant could be the open and enduring expression of G-d’s love for His creation. It was G-d’s promise to all living creatures that He would never again obliterate all land-life from the world, as stated in Genesis 9:11 – “never again will there be a flood to destroy the earth.” The Covenant of the Rainbow has an inner meaning as well: it was G-d’s promise that He would always accept a person’s sincere personal repentance if it was directed to Him. From that point on, G-d endowed mankind with the ability to seek and gain His forgiveness, and with this He insured that a person’s freedom to choose good includes the strength to prevail over animalistic and self-centered desires.
Still, the Seven Commandments received by Noah could have been challenged at a later time by any charismatic misleader who also claimed to be a prophet, and how would a person know which course to follow? This points to the singular importance of the revelation at Mount Sinai to the Jewish people, 50 days after G-d brought them out from slavery in Egypt. At Mount Sinai, the Creator revealed Himself to a nation of at least three million of people, making them all witnesses to testify to their future children and the world, so that no person in any generation could arise to seriously refute the prophecy and instruction which Moses received, which is called the Torah. Included in the Torah was the Noahide Code, to be preserved for the generations of mankind.
The entire Book of Genesis, and the Book of Exodus up to and including the arrival of the Israelites at Mount Sinai, were dictated by G-d to Moses when they arrived there. There was then a first covenant made between G-d and the Israelites on that first part of the Written Torah, which included their acceptance of the Noahide Code. Thus, the Divine moral code of Seven (Universal) Commandments was renewed, after it had become neglected by the rest of the nations. That was four days before the Ten (Jewish) Commandments were spoken openly by G-d to all of the Israelites, at which point they became the Jewish people.
At Mount Sinai, G-d taught the essentials of the Torah’s precepts through Moses, and this is called the Oral Torah. Included in this are the details of G-d’s directive for all Gentiles to observe their Seven Noahide Commandments. These details, as G-d specified them to Moses, are the true foundation of the universal Noahide Code. A righteous Gentile merits to receive a place in the eternal future World to Come, in the Messianic Era, through observance of these commandments. That is a Gentile’s part in the Torah of Moses, which is G-d’s “Tree of Life” (Proverbs 3:18). It all begins with recognizing the perfect Unity of the Creator.