Why did God create the world? A hard question to answer. Maybe only God knows. Nonetheless 4 answers have been suggested.
The 4 answers to why did God create the world correspond to the 4 letters of the His essential Name Havayah.
The first answer is that God has an irrational passion, as it were, to create for Himself a dwelling below.
The 2nd answer is that God wants to be known by others. The 3rd – God wants to shower goodness on others. The 4th – a king needs a people.
Obviously, all of these answers are no more than a glimpse from afar, for we can never really why God created the world and why we are here.