Srimad Bhagavatam Canto 09, Chapter 24, Text 58

SB 9.24.58

yan maya-cestitam pumsah
 sthity-utpatty-apyayaya hi
anugrahas tan-nivrtter
 atma-labhaya cesyate
Translation by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
The Supreme Personality of Godhead acts through His material energy in the creation, maintenance and annihilation of this cosmic manifestation just to deliver the living entity by His compassion and stop the living entity’s birth, death and duration of materialistic life. Thus He enables the living being to return home, back to Godhead.
Purport by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
Materialistic men sometimes ask why God has created the material world for the suffering of the living entities. The material creation is certainly meant for the suffering of the conditioned souls, who are part of the Supreme Personality of Godhead, as confirmed by the Lord Himself in Bhagavad-gita (15.7):
mamaivamso jiva-loke
 jiva-bhutah sanatanah
manah sasthanindriyani
 prakrti-sthani karsati
“The living entities in this conditioned world are My eternal, fragmental parts. Due to conditioned life, they are struggling very hard with the six senses, which include the mind.” All the living entities are part and parcel of the Supreme Personality of Godhead and are as good as the Lord qualitatively, but quantitatively there is a great difference between them, for the Lord is unlimited whereas the living entities are limited. Thus the Lord possesses unlimited potency for pleasure, and the living entities have a limited pleasure potency. Anandamayo ’bhyasat (Vedanta-sutra 1.1.12). Both the Lord and the living entity, being qualitatively spirit soul, have the tendency for peaceful enjoyment, but when the part of the Supreme Personality of Godhead unfortunately wants to enjoy independently, without Krsna, he is put into the material world, where he begins his life as Brahma and is gradually degraded to the status of an ant or a worm in stool. This is called manah sasthanindriyani prakrti-sthani karsati. There is a great struggle for existence because the living entity conditioned by material nature is under nature’s full control (prakrteh kriyamanani gunaih karmani sarvasah). Because of his limited knowledge, however, the living entity thinks he is enjoying in this material world. Manah sasthanindriyani prakrti-sthani karsati. He is actually under the full control of material nature, but still he thinks himself independent (ahankara-vimudhatma kartaham iti manyate). Even when he is elevated by speculative knowledge and tries to merge into the existence of Brahman, the same disease continues. Aruhya krcchrena param padam tatah patanty adhah (Bhag. 10.2.32). Even having attained that param padam, having merged into the impersonal Brahman, he falls again to the material world.
In this way, the conditioned soul undergoes a great struggle for existence in this material world, and therefore the Lord, out of compassion for him, appears in this world and instructs him. Thus the Lord says in Bhagavad-gita (4.7):
yada yada hi dharmasya
 glanir bhavati bharata
abhyutthanam adharmasya
 tadatmanam srjamy aham
“Whenever and wherever there is a decline in religious practice, O descendant of Bharata, and a predominant rise of irreligion — at that time I descend Myself.” The real dharma is to surrender unto Krsna, but the rebellious living entity, instead of surrendering to Krsna, engages in adharma, in a struggle for existence to become like Krsna. Therefore out of compassion Krsna creates this material world to give the living entity a chance to understand his real position. Bhagavad-gita and similar Vedic literatures are presented so that the living being may understand his relationship with Krsna. Vedais ca sarvair aham eva vedyah (Bg. 15.15). All these Vedic literatures are meant to enable the human being to understand what he is, what his actual position is, and what his relationship is with the Supreme Personality of Godhead. This is called brahma-jijñasa. Every conditioned soul is struggling, but human life provides the best chance for him to understand his position. Therefore this verse says, anugrahas tan-nivrtteh, indicating that the false life of repeated birth and death must be stopped and the conditioned soul should be educated. This is the purpose of the creation.
The creation does not arise whimsically, as atheistic men think.
asatyam apratistham te
 jagad ahur anisvaram
 kim anyat kama-haitukam
“They say that this world is unreal, that there is no foundation and that there is no God in control. It is produced of sex desire and has no cause other than lust.” (Bg. 16.8) Atheistic rascals think that there is no God and that the creation has taken place by chance, just as a man and woman meet by chance and the woman becomes pregnant and gives birth to a child. Actually, however, this is not the fact. The fact is that there is a purpose for this creation: to give the conditioned soul a chance to return to his original consciousness, Krsna consciousness, and then return home, back to Godhead, and be completely happy in the spiritual world. In the material world the conditioned soul is given a chance to satisfy his senses, but at the same time he is informed by Vedic knowledge that this material world is not his actual place for happiness. Janma-mrtyu-jara-vyadhi-duhkha-dosanudarsanam (Bg. 13.9). One must stop the repetition of birth and death. Every human being, therefore, should take advantage of this creation by understanding Krsna and his relationship with Krsna and in this way return home, back to Godhead.
Srimad Bhagavatam Canto 09, Chapter 24, Text 57
Srimad Bhagavatam Canto 09, Chapter 24, Text 59