In the idiom of the Midrash, G-d created the world in order "to have a home in the lower realms," which means so He could be present in the realm not inherently conducive to the awareness of His presence. The blueprint He prepared for creating the world so it would fulfill this purpose is the Torah. In this sense, the Torah "preceded" creation, just as the plan precedes the execution.
This world, however, is just the stage on which the cosmic drama of making a home for G-d "in the lower realms" is to be played. The protagonists in this drama are the human race, on whom G-d made the accomplishments of this goal dependent. The conscious essence of a human being is its soul. Every soul has a unique role to play in making reality into G-d's home; this unique task gives rise to the soul's unique personality. The world, thus, was created both for the sake of the Torah and for the sake of humanity.
Inasmuch as the world was created in accordance with the vision, purpose, and plan specified in the Torah, the Torah also constitutes humanity's quintessential guidebook -- our instructions how to live life in order to fulfill our purpose.
Nonetheless, before detailing these instructions, the Torah first describes the creation of the world and the genesis of the Jewish people. The digression is required in order to explain how the task of fulfilling G-d's purpose on earth eventually necessitated the existence of a unique nation among the human race -- the Jewish people -- living life according to the Torah in the context of a specific homeland -- the Promised Land of Israel. The Torah therefore describes how the necessity for a chosen people living in a chosen land came about.
This creation account establishes G-d, the Creator, as the true "owner" of the entire world. This sovereignty would allow Him, when the time would come, to expropriate the future Jewish homeland from the people whom He allowed to occupy it in the meantime.
G-d created everything that exists, so He is therefore beyond all categories of existence and beyond any description. Even terms such as "infinite," "transcendent," and "eternal" cannot help us define Him; He created all these categories, so He is beyond them all.
By the same token, G-d is beyond any category of gender, so when we speak of Him in the masculine it is because the neuter "It" is too impersonal (and in fact, there is no neuter in Hebrew) and because by assuming the role of the Creator of a universe, He adopts, mainly, the attributes that He will define in the context of this world as masculine.
Despite this inscrutability, G-d makes Himself at all times accessible to His creatures. Significantly, He chose to create reality by first assuming specific attributes that serve to channel His creative energy. Everything created thus reflects these Divine attributes in one way or another, and therefore, by observing creation through the lens of G-d's revealed teachings, we can gradually come to know G-d Himself.
Prologue to Kehot's Chumash