The reason God created the earth was so that He could make man in His own image, Give us a beautiful place to live - as the earth was perfect then, And have fellowship with us just as He did with Adam when He would walk in the cool of the evening with Adam.
Unfortunately MAN has polluted the earth and used it badly and not cared for it in the way God commanded Adam to do so, Therefore we have ruined it and that's why eventually, Jesus will have to come back for a second time to sort things out.
Unfortunately, When He does return for His second coming, Jesus will be coming in flaming fire, Taking vengeance on those who do not know God and on those who do not OBEY the gospel of our Lod Jesus Christ, And these shall be punished with everlasting destruction from the presence of the Lord and from the glory of His power etc (2 Thessalonians 1: 8 & 9)
Well we don't actually know why he did it only the fact that he did it so all we can do about it is believe in him that he knows what he is doing I mean even the Bible tells us only how he created everything and not why so. . .
God did not create the earth at all. There is no god. Because there is not god, And god didn't create the world at all that means there is no reason WHY god created the earth. There is only a reason why god created the earth if he actually did create the earth the answer is no.