In the beginning of G-d's creation of heaven and earth.
We are taught in the Midrash that G-d created the world as a "lower realm" -- i.e., a realm initially devoid of Divine consciousness, and even opposed to it -- intending that humanity fill the world with Divine consciousness. The tool that G-d gave humanity in order to enable it to perform this feat is the Torah. The drama of creation thus required three elements: the world, the human race, and the Torah, serving respectively as the setting, the actors, and the script.
G-d gave humanity the free choice to ignore Him and His intentions for the world, and this is exactly what the early generations did. In keeping with His decision to grant free choice, G-d obliged, so to speak, by removing His revelation from the world, hiding progressively further behind the facade of nature.
In response to most of humanity's choice to ignore Him, G-d implemented his "contingency plan": he took one family that continued to nurture the original ideal of Divine consciousness and forged them into a nation -- with whom He then entrusted the mission of fulfilling His original purpose for creation. The Jewish people would both serve as an inspiration and example for the rest of humanity and encourage them to play their role in His scheme for transforming the world into His home.
The Book of Genesis is the chronicle of how the creation of the Jewish people became necessary and how it came to be.