As much as I have understood from the Shi'ite teachings this world, Dunya (which means closer, or less precious), is a projection of a more realistic world which we call Barzakh, being somewhat a surface to a deep universe, and Barzakh on its own is the projection of a more realistic world which we call Akherah, apparently again like a surface to a deeper universe. So that one can assume the real world a many (finite or infinite?) dimensional universe, Barzakh being comprised of a set of its subspaces and Dunya being comprised of a set of Barzakh's subspaces. I am even not sure if multi-dimension would mean 4, 5, 6 or more dimensional, maybe it would be even a fractal dimension or a real number dimensional (NOTE. our sensed three dimensional space is full of holes in the microscopic scales so that one can even expect Dunya not being three dimensional). Anyway, this is off-topic to this question. Death in Dunya is actually a travel from the upper surface of the universe toward inside of it, Barzakh, and resurrection would be a death from Barzakh to Akherah, again a travel toward deeper inside. The deeper volumes are also always called to be the reality behind the surface, the hidden truth by the surface. The uppest surface, Dunya, is pleased for the Worldly life but we are then warned not to forget the truth. A witness from Quran for that Akherah exists even now and Barzakh also exists for us even before our death in this surface world is [29:54]:
يَسْتَعْجِلُونَكَ بِالْعَذَابِ وَإِنَّ جَهَنَّمَ لَمُحِيطَةٌ
بِالْكَافِرِينَ
they urge you to hasten the punishment. and indeed, hell has been already
encompassing of the disbelievers {this verse is most of the times translated not very precisely}
that is, they are already in hell but they don't understand it. Since this world is created to show things almost irrespective of its truth:
فَلَولا إِذ جاءَهُم بَأسُنا تَضَرَّعوا وَلـٰكِن قَسَت قُلوبُهُم
وَزَيَّنَ لَهُمُ الشَّيطـٰنُ ما كانوا يَعمَلونَ
Then why, when Our punishment came to them, did they not humble
themselves? But their hearts became hardened, and Satan made
attractive to them that which they were doing [6:43]
or
... فَيُحِلّوا ما حَرَّمَ اللَّـهُ ۚ زُيِّنَ لَهُم سوءُ أَعمـٰلِهِم ۗ
وَاللَّـهُ لا يَهدِى القَومَ الكـٰفِرينَ
... [they] make lawful what Allah has made unlawful. Made pleasing to
them is the evil of their deeds; and Allah does not guide the
disbelieving people. [9:37]
and many other verses reporting about this pleasing mechanism, a most important mechanism of Dunya acting against the Humans and Jinns. Also see this verse:
لَقَد كُنتَ فى غَفلَةٍ مِن هـٰذا فَكَشَفنا عَنكَ غِطاءَكَ فَبَصَرُكَ
اليَومَ حَديدٌ
[It will be said], "You were certainly in unmindfulness of this, and
We have removed from you your cover, so your sight, this Day, is
sharp." [50:22]
or that Allah says:
... إِنَّهُ يَعلَمُ الجَهرَ وَما يَخفىٰ
... Indeed, He knows what is Overt and what it [the overt thing]
hides. [87:7] {This verse is not usually translated precisely}
that is, what is known would cover what is not known, but Allah knows all. Or that Allah says:
فَسُبحـٰنَ الَّذى بِيَدِهِ مَلَكوتُ كُلِّ شَىءٍ وَإِلَيهِ تُرجَعونَ
So exalted is He in whose hand is the realm of all things, and to Him
you will be returned. [36:83]
Also see the following verse which report a same news about this world having a hidden truth covered by a surface which we call Dunya:
إِنَّ الَّذينَ يَكتُمونَ ما أَنزَلَ اللَّـهُ مِنَ الكِتـٰبِ
وَيَشتَرونَ بِهِ ثَمَنًا قَليلًا ۙ أُولـٰئِكَ ما يَأكُلونَ فى
بُطونِهِم إِلَّا النّارَ وَلا يُكَلِّمُهُمُ اللَّـهُ يَومَ القِيـٰمَةِ
وَلا يُزَكّيهِم وَلَهُم عَذابٌ أَليمٌ
Indeed, they who conceal what Allah has sent down of the Book and
exchange it for a small price - those consume not into their bellies
except the Fire. And Allah will not speak to them on the Day of
Resurrection, nor will He purify them. And they will have a painful
punishment. [2:174]
or:
إِنَّ الَّذينَ يَأكُلونَ أَموٰلَ اليَتـٰمىٰ ظُلمًا إِنَّما
يَأكُلونَ فى بُطونِهِم نارًا ۖ وَسَيَصلَونَ سَعيرًا
Indeed, those who devour the property of orphans unjustly are only
consuming into their bellies fire. And they will be burned in a Blaze.
[4:10]
We are then giving a body which we call it the material body, but we are also given a hearth (different than the limb, though there is a relation between them, and a better relation exists between that and brain). The hearth is a door to the deeper inside truth. So that each person is at the same time experiencing life inside an inner universe (to some extent having intersections with other people's inner universe) and inside the outer universe, Dunya. When we fall into asleep, our bodily eyes are closed, but we can see, we have yet a body, we can hear and etc., if the dream is among the honest ones this is a journey in the inner universe, although if we are not treated enough we may see things symbolic, that is, not very realistically. Maybe Jinn's live in some more inner layers of Dunya, maybe Tay ul-Arz and similar things all happen in those inner layers of the universe, having seemingly more spatial dimensions than Dunya.
Now we reach to the place to be able to talk about the purpose for Allah to create the universe in such a layered structure. The answer is simple, the very creation of Humans and Jinn's require such a creation as a mean for their evolution and improvement. Allah put us in a world whose sensed reality is different from its real but hidden truth, then guides us toward the real truth and warns us not to adhere to the adornments provided in this illusion which we call Dunya:
وَما أوتيتُم مِن شَىءٍ فَمَتـٰعُ الحَيوٰةِ الدُّنيا وَزينَتُها ۚ وَما
عِندَ اللَّـهِ خَيرٌ وَأَبقىٰ ۚ أَفَلا تَعقِلونَ
And whatever thing you [people] have been given - it is [only for] the
enjoyment of worldly life and its adornment. And what is with Allah is
better and more lasting; so will you not use reason? [28:60]
and
وَاصبِر نَفسَكَ مَعَ الَّذينَ يَدعونَ رَبَّهُم بِالغَدوٰةِ وَالعَشِىِّ
يُريدونَ وَجهَهُ ۖ وَلا تَعدُ عَيناكَ عَنهُم تُريدُ زينَةَ الحَيوٰةِ
الدُّنيا ۖ وَلا تُطِع مَن أَغفَلنا قَلبَهُ عَن ذِكرِنا وَاتَّبَعَ
هَوىٰهُ وَكانَ أَمرُهُ فُرُطًا
And keep yourself patient [by being] with those who call upon their
Lord in the morning and the evening, seeking His countenance. And let
not your eyes pass beyond them, desiring adornments of the worldly
life, and do not obey one whose heart We have made heedless of Our
remembrance and who follows his desire and whose affair is ever [in]
neglect. [18:28]
So that Dunya is a place to choose, choose between what intellect orders us to do (or to avoid) and what desire asks us to do for it to be satisfied more and more. Allah will never force anyone by uncovering the truth, as He has said in Surah Ya-Sin:
And there came from the farthest end of the city a man, running. He
said, "O my people, follow the messengers. (20) Follow those who do
not ask of you [any] payment, and they are [rightly] guided. (21) And
why should I not worship He who created me and to whom you will be
returned? (22) Should I take other than Him [false] deities [while],
if the Most Merciful intends for me some adversity, their intercession
will not avail me at all, nor can they save me? (23) Indeed, I would
then be in manifest error. (24) Indeed, I have believed in your Lord,
so listen to me." (25) It was said, "Enter Paradise." He said, "I
wish my people could know (26) Of how my Lord has forgiven me and
placed me among the honored." (27) And We did not send down upon his
people after him any soldiers from the heaven, nor would We have
done so. (28)
The truth will be covered from our senses until death comes or someone treats himself to become such good that the hidden universe will be shown to him:
وَكَذٰلِكَ نُرى إِبرٰهيمَ مَلَكوتَ السَّمـٰوٰتِ وَالأَرضِ وَلِيَكونَ
مِنَ الموقِنينَ
And thus did We show Abraham the realm of the heavens and the earth
that he would be among the certain [in faith] [6:75]
Actually there are many who was known to be able to see the Barzakh before they die, seeing the realm of what they are eating (if it is Halal or not), where they are praying and etc., but to this position no one reaches unless he will first be submitted to Allah, there would be no other reason then for Allah to cover things from such a man, he has already passed the "making choice exam"!
However, you see there are many other living species that live in this world while they are not going to make a choice, this is partly because they were creatable in this universe and God never choose what to create and what not to create, and partly because we are told that the whole universe is created for us to benefit, every such species have something to do for the whole thing to remain stable and the system simply works!
Least but by no means mention that Dunya is merely a bonus level, for us to know our weaknesses and to improve toward a complete humanity. However, there are those who try to improve and those who want only to live the easy life. For those who try to improve this world is somewhat a bonus level, in one Qadr Night one can improve like in thousands of months, and even the whole life of a human being (all the joys and suffers during the years which we count) is less than a real day
... وَإِنَّ يَومًا عِندَ رَبِّكَ كَأَلفِ سَنَةٍ مِمّا تَعُدّونَ
And indeed, a day with your Lord is like a thousand years of those
which you count. [22:47]
قـٰلَ كَم لَبِثتُم فِى الأَرضِ عَدَدَ سِنينَ / قالوا لَبِثنا يَومًا
أَو بَعضَ يَومٍ فَسـَٔلِ العادّينَ / قـٰلَ إِن لَبِثتُم إِلّا قَليلًا
ۖ لَو أَنَّكُم كُنتُم تَعلَمونَ
[Allah] will say, "How long did you remain on earth in number of
years?" / They will say, "We remained a day or part of a day; ask
those who enumerate." / He will say, "You stayed not but a little - if
only you had known. [23:112,113,114]
But even during such a short time one can reach to the highest rank among all the creatures of Allah, like the prophets and Imams reached such a position! However, if someone lose this opportunity then he would led toward the hell therein being purified as much as possible, and ... So that even Hell is a mean for Allah to apply his mercy to the human being, although it will be very much suffering and not as easy as the life in Dunya was, actually very very hard for our minds today to understand it, the cost for getting purified of what we have acquired by ourselves.
Godspeed