In the beginning God created the heavens and the Earth. God had the purpose of forming this special creation for His Glory and His pleasure. He says that in a number of places, but very specifically in Hebrews 1:1-2
God, who at sundry times and in divers manners spake in time past unto the fathers by the prophets, hath in these last days spoken unto us by his Son, whom he hath appointed heir of all things, by whom also he made the worlds;
And He made a Covenant within the Godhead (Father, Son and Holy Spirit) to redeem a people for Himself. Read the complete book of Hebrews. (13 chapters of pure and sound doctrine)
Also, Revelation 4:11
Thou art worthy, O Lord, to receive glory and honour and power: for thou hast created all things, and for thy pleasure they are and were created.
So, it was in God’s mind to create this universe, mankind, the fall, sin, death, and to send Christ in time to redeem a people for His Glory. God planned all this before the foundation of the world. Read Ephesians 1 very carefully.