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 is completely saturated with devotion
SB Canto 5
Desiring to get a perfect son and become an inhabitant of Pitṛloka, Mahārāja Āgnīdhra once worshiped Lord Brahmā, 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.
The King became pitṛloka-kāma, or desirous of being transferred to the planet named Pitṛloka. Pitṛloka is mentioned in Bhagavad-gītā (yānti deva-vratā devān pitṟn yānti pitṛ-vratāḥ (BG 9.25)). To go to this planet, one needs very good sons who can make offerings to Lord Viṣṇu and then offer the remnants to their forefathers. The purpose of the śrāddha ceremony is to please the Supreme Personality of Godhead, Lord Viṣṇu, so that after pleasing Him one may offer prasāda to one's forefathers and in this way make them happy. The inhabitants of Pitṛloka are generally men of the karma-kāṇḍīya, 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 viṣṇu-prasāda. Everyone in heavenly planets such as Pitṛloka, however, must return to earth after exhausting the effects of his pious acts. As confirmed in Bhagavad-gītā (9.21), kṣīṇe puṇye martya-lokaṁ viśanti: 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 Mahārāja Priyavrata was a great devotee, how could he have begotten a son who desired to be transferred to Pitṛloka? Lord Kṛṣṇa says, pitṟn yānti pitṛ-vratāḥ: persons who desire to go to Pitṛloka are transferred there. Similarly, yānti mad-yājino 'pi mām: (BG 9.25) persons who desire to be transferred to the spiritual planets, Vaikuṇṭhalokas, can also go there. Since Mahārāja Āgnīdhra was the son of a Vaiṣṇava, he should have desired to be transferred to the spiritual world, Vaikuṇṭhaloka. Why, then, did he desire to be transferred to Pitṛloka? In answer to this, Gosvāmī Giridhara, one of the Bhāgavatam commentators, remarks that Āgnīdhra was born when Mahārāja 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 garbhādhāna-saṁskāra 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 garbhādhāna-saṁskāras, and therefore people generally have a lusty attitude when they beget children. Especially in this age of Kali, there are no garbhādhāna ceremonies; everyone enjoys sex with his wife like a cat or dog. Therefore according to śāstric injunctions, almost all the people of this age belong to the śūdra category. Of course, although Mahārāja Āgnīdhra had a desire to be transferred to Pitṛloka, this does not mean that his mentality was that of a śūdra; he was a kṣatriya.
Mahārāja Āgnīdhra desired to be transferred to Pitṛloka, and therefore he needed a wife because anyone desiring to be transferred to Pitṛloka must leave behind a good son to offer yearly piṇḍa, or prasāda from Lord Viṣṇu. To have a good son, Mahārāja Āgnīdhra 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 Brahmā. In Bhagavad-gītā (4.12) it is said, kāṅkṣantaḥ karmaṇāṁ siddhiṁ yajanta iha devatāḥ: materialists who want quick results in the material world worship demigods. This is also confirmed in Śrīmad-Bhāgavatam. Śrī-aiśvarya-prajepsavaḥ: 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, Viṣṇu.