dharmaṁ cāvekṣya dharmavit
smarañ chukra-vacaḥ kāle
rāja-putryā—by Śarmiṣṭhā, who was the daughter of a king; arthitaḥ—being requested; apatye—for a son; dharmam—religious principles; ca—as well as; avekṣya—considering; dharma-vit—aware of all religious principles; smaran—remembering; śukra-vacaḥ—the warning of Śukrācārya; kāle—at the time; diṣṭam—circumstantially; eva—indeed; abhyapadyata—accepted (to fulfill the desire of Śarmiṣṭhā).
When Princess Śarmiṣṭhā begged King Yayāti for a son, the King was certainly aware of the principles of religion, and therefore he agreed to fulfill her desire. Although he remembered the warning of Śukrācārya, he thought of this union as the desire of the Supreme, and thus he had sex with Śarmiṣṭhā.
King Yayāti was completely aware of the duty of a kṣatriya. When a kṣatriya is approached by a woman, he cannot deny her. This is a religious principle. Consequently, when Dharmarāja, Yudhiṣṭhira, saw Arjuna unhappy after Arjuna returned from Dvārakā, he asked whether Arjuna had refused a woman who had begged for a son. Although Mahārāja Yayāti remembered Śukrācārya’s warning, he could not refuse Śarmiṣṭhā. He thought it wise to give her a son, and thus he had sexual intercourse with her after her menstrual period. This kind of lust is not against religious principles. As stated in Bhagavad-gītā (7.11), dharmāviruddho bhūteṣu kāmo ’smi: sex life not contrary to the principles of religion is sanctioned by Kṛṣṇa. Because Śarmiṣṭhā, the daughter of a king, had begged Yayāti for a son, their combination was not lust but an act of religion.
Link to this page: https://prabhupadabooks.com/sb/9/18/32