The Qur'an mentions several purposes for creation. So to connect them, the main purpose must be identified. Verse 11:119 says that mankind was created for رحم Rahma:
الا من رحم ربك ولذلك خلقهم
11:119 Except those upon whom your Sustainer/Developer has bestowed His grace/unselfish bestowal of potential and growth. And to this end has He created them.
Rahma comes from the root Ra-Ha-Mim and refers to providing to the needs so such persons can grow. Mufsarin at-Tabataba'i says it means 'giving and bestowing to fulfill other's need'1. A womb is called 'rahim' (pl:Arhaam)2, as it bestows everything the foetus needs to develop and grow. Thus development is one of our purposes of existence.
The second most important verse on this subject is 51:56, which says the God created us only to serve Him3. And how do we serve Him? This is explained in another verse that talks about our purpose of creation:
وهو الذى خلق السموت والارض فى ستة ايام وكان عرشه على الماء ليبلوكم ايكم احسن عملا ولىن قلت انكم مبعوثون من بعد الموت ليقولن الذين كفروا ان هذا الا سحر مبين
11:7 He is the One who created the heavens and earth in six periods, and His dominion was upon the water, and to test who from amongst you works the best. When you say, "You will be resurrected after death." those who rejected will say, "This is but clear magic!"
The explaining part is: ليبلوكم ايكم احسن عمل liyabluwakum ayyukum ahsanu AAamalan
li/for yabluwa/To test/trial/experiment/favour kum/you ayyakum/among you ahsanu/conducts the best/most proper/most benefitting/balancing amalan/works/acts/deeds/conduct.
Yabluwa is a verb from the root Ba-Lem-Waw4, and means to test, to trial, to experiment, to esteem, to honour, to favour. Thus the test/trial/experiment of life is a favour and honour for us humans.
Ahsanu is a verb from the root Ha-Sin-Nun5, and refers to something or someone possessing and excells in the qualities of being good, well balanced, properly ordered and being beneficial and pleasing to others.
So these combined explain our purpose of existence:
We are to develop as conscious beings, and our level of development is shown by how much 'حسن Hasana' we have done, how balanced and beneficial we are in this universe.
As expressed by the Qur'an:
لتركبن طبقا عن طبق
84:19 You (Mankind) shall surely embark from stage to stage.
And through this we can understand why God created the universe, as providing development is a manifestation of Him:
يسله من فى السموت والارض كل يوم هو فى شان
55:29 On Him depends all creatures in the heavens and on earth; [and] every day He manifests Himself in yet another way.
بسم الله الرحمن الرحيم
1:1 With the power and definition of Allah, the Absolute. The Ultimate Source of Instant Beneficence and Eternal Mercy. Who encompasses the entire Universe, nourishing and taking care of all things for what they are meant to be; just as a mother's womb nourishes the embryo to completion without any returns.
Footnotes:
1. Edward Lane, Arabic-English Lexicon, volume 3, page 221-223. Allamah as-Sayyid Muhammad Husayn at-Tabataba'i, Al-Mizan, English translation, page 22.
2. Hans Wehr, Arabic-English Dictionary, page 384.
3. 51:56 وما خلقت الجن والانس الا ليعبدون I did not create the Jinn and the humans except to serve Me.
4.Abdul Mannan Omar, Dictionary of the Holy Qur'an, page 64-65.
5.Abdul Mannan Omar, Dictionary of the Holy Qur'an, page 124. Oliver Leaman (Ed.), The Qur'an: an encyclopedia, page 252-253. Edward Lane, Arabic-English Lexicon, volume 3, page 206-208.