Shankara said Svadharma is necessary for purity of mind:
One who is passionately devoted to the authority of the Śrutis
acquires steadiness in his Svadharma, which alone conduces to the
purity of his mind. The man of pure mind realises the Supreme Self,
and by this alone Samsara with its root is destroyed. (Vivekachudamani
148)
And according to Shankara, an unenlightened person shouldn't give up his Svadharma.
An excerpt from Shankara's commentary on Bhagavad Gita 18.48:
Kaunteya, O son of Kunti; na tyajet, one should not give up;-what?-the
karma, duty; sahajam, to which one is born, which devolves from the
very birth; api, even though; it be sadosam, faulty, consisting as it
is of the three gunas. Hi, for; sarva-arambhah, all undertakings
(-whatever are begun are arambhah, i.e. ‘all actions’, according to
the context-), being constituted by the three gunas (-here, the fact
of being constituted by the three gunas is the cause-); are avrtah,
surrounded; dosena, with evil; iva, as;; agnih, fire; is dhumena, with
smoke, which comes into being concurrently. One does not get freed
from evil by giving up the duty to which one is born-called one’s own
duty-, even though (he may be) fulfilling somebody else’s duty.
Another’s duty, too, is fraught with fear. The meaning is: Since action cannot be totally given up by an unenlightened person, therefore he should not relinquish it.