Srimad Bhagavatam Canto 05, Chapter 02, Text 02

SB 5.2.2

sa ca kadacit pitrloka-kamah sura-vara-vanitakridacala-dronyam bhagavantam visva-srjam patim abhrta-paricaryopakarana atmaikagryena tapasvy aradhayam babhuva.
Translation by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
Desiring to get a perfect son and become an inhabitant of Pitrloka, Maharaja Agnidhra once worshiped Lord Brahma, the master of those in charge of material creation. He went to a valley of Mandara Hill, where the damsels of the heavenly planets come down to stroll. There he collected garden flowers and other necessary paraphernalia and then engaged in severe austerities and worship.
Purport by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
The King became pitrloka-kama, or desirous of being transferred to the planet named Pitrloka. Pitrloka is mentioned in Bhagavad-gita (yanti deva-vrata devan pitrn yanti pitr-vratah). To go to this planet, one needs very good sons who can make offerings to Lord Visnu and then offer the remnants to their forefathers. The purpose of the sraddha ceremony is to please the Supreme Personality of Godhead, Lord Visnu, so that after pleasing Him one may offer prasada to one’s forefathers and in this way make them happy. The inhabitants of Pitrloka are generally men of the karma-kandiya, or fruitive activities category, who have been transferred there because of their pious activities. They can stay there as long as their descendants offer them visnu-prasada. Everyone in heavenly planets such as Pitrloka, however, must return to earth after exhausting the effects of his pious acts. As confirmed in Bhagavad-gita (9.21), ksine punye martya-lokam visanti: persons who perform pious acts are transferred to higher planets, but when the effects of their pious acts are over, they are again transferred to earth.
Since Maharaja Priyavrata was a great devotee, how could he have begotten a son who desired to be transferred to Pitrloka? Lord Krsna says, pitrn yanti pitr-vratah: persons who desire to go to Pitrloka are transferred there. Similarly, yanti mad-yajino ’pi mam: persons who desire to be transferred to the spiritual planets, Vaikunthalokas, can also go there. Since Maharaja Agnidhra was the son of a Vaisnava, he should have desired to be transferred to the spiritual world, Vaikunthaloka. Why, then, did he desire to be transferred to Pitrloka? In answer to this, Gosvami Giridhara, one of the Bhagavatam commentators, remarks that Agnidhra was born when Maharaja Priyavrata was infatuated by lusty desires. This may be accepted as a fact because sons are begotten with different mentalities according to the time of their conception. According to the Vedic system, therefore, before a child is conceived, the garbhadhana-samskara is performed. This ceremony molds the mentality of the father in such a way that when he plants his seed in the womb of his wife, he will beget a child whose mind will be completely saturated with a devotional attitude. At the present moment, however, there are no such garbhadhana-samskaras, and therefore people generally have a lusty attitude when they beget children. Especially in this Age of Kali, there are no garbhadhana ceremonies; everyone enjoys sex with his wife like a cat or dog. Therefore according to sastric injunctions, almost all the people of this age belong to the sudra category. Of course, although Maharaja Agnidhra had a desire to be transferred to Pitrloka, this does not mean that his mentality was that of a sudra; he was a ksatriya.
Maharaja Agnidhra desired to be transferred to Pitrloka, and therefore he needed a wife because anyone desiring to be transferred to Pitrloka must leave behind a good son to offer yearly pinda, or prasada from Lord Visnu. To have a good son, Maharaja Agnidhra wanted a wife from a family of demigods. Therefore he went to Mandara Hill, where the women of the demigods generally come, to worship Lord Brahma. In Bhagavad-gita (4.12) it is said, kanksantah karmanam siddhim yajanta iha devatah: materialists who want quick results in the material world worship demigods. This is also confirmed in Srimad-Bhagavatam. Sri-aisvarya-prajepsavah: those who desire beautiful wives, substantial wealth and many sons worship the demigods, but an intelligent devotee, instead of being entangled by the happiness of this material world in the form of a beautiful wife, material opulence and children, desires to be immediately transferred back home, back to Godhead. Thus he worships the Supreme Personality of Godhead, Visnu.
Srimad Bhagavatam Canto 05, Chapter 02, Text 01