Why did God create everything?
Allah says in His Quran He did not create all of this for any foolish purpose. Allah Says:
And I did not Create the jinn and humans except they should worship Me.
[Noble Quran 51:56]
He created us for the purpose of worshiping Him, Alone and without any partners.
And He it is Who has created the heavens and the earth in six Days and His Throne was on the water, that He might try you, which of you is the best in deeds. But if you were to say to them: "You shall indeed be raised up after death," those who disbelieve would be sure to say, "This is nothing but obvious magic."
[Noble Quran 11:7]
Allah has created all we call the universe as a test for us. This is not our final destination. What we might consider to be "bad" or "good" could actually be quite the opposite.
Blessed is He in Whose Hand is the dominion, and He has the Ability to do all things.
(He's the One) Who has created death and life, so He may test you which of you is best in deed. And He is the All-Mighty, the Oft-Forgiving;
(He's the One) Who has created the seven heavens one above another, you can see no fault in the creations of the Most Beneficent. Then look again: "Can you see any rifts?"
Then look again and yet again, your sight will return to you in a state of humiliation and worn out.
[Noble Quran 67:1-4]
The Quran tells us about the nature of mankind and how quickly we forget the many wonderful blessings provided to us daily. Allah describes our attitude clearly in His Quran:
And when some hurt touches man, he cries to his Lord (Allah Alone), turning to Him in repentance, but when He bestows a favor upon him from Himself, he forgets that for which he cried for before, and he sets up rivals to Allah, in order to mislead others from His Path. Say: "Take pleasure in your disbelief for a while: surely, you are (one) of the dwellers of the Fire!"
[Noble Quran 39:8]
We forget, as we were created to forget. And this is a part of our test. Will we only use a selective memory and overlook what we owe to our Creator and Sustainer? Or will we be appreciative even when we are suffering some hardship or setback in this life?
As for mankind, whenever his Lord tests him giving him honor and gifts, he says (bragging): "My Lord honors me."
But whenever He tests him by withholding his livelihood, he says: "My Lord has disgraced me!"
[Noble Quran 89:15-16]
Then Allah makes clear to us the real reasoning behind all that is taking place:
Nay! But (it is because) you do not treat orphans with kindness and generosity.
And you do not encourage feeding of the poor!
And you devour inheritance with greed,
And you love wealth with abounding love!
[Noble Quran 89:17-20]
Allah has created us and given us so much, yet we are so careless concerning His Right to be worshipped exclusively and deny the Day of Judgment wherein we will all be asked concerning His Generosity.
O man! What has made you careless concerning your Lord, the Most Generous?
Who created you, fashioned you perfectly, and gave you due proportion;
In whatever form He willed, He put you together.
Nay! But you deny the Recompense (reward for good deeds and punishment for evil deeds).
[Noble Quran 82:6-9]
And how will we view our condition and surroundings? And how will we treat others around us? Are we considerate of others and are we quick to blame or quick to forgive? All of these things are a part of our test, the things we will be asked about on the Day of Judgment.
------------------