Through love of God one may enter into matters such as a “Transgression for its own sake,” as did Yael, though we do not find any explicit dispensation in the Torah for this action. Rather, it is from this incident that we derive this. That is, because of her own great desire and love for the salvation of Israel, and in order to destroy such a great enemy of God such as Sisera, she did not take into consideration her transgression, and the foulness that he cast into her although, as the Sages say, she regarded her act as wrong.
Nevertheless, she sacrificed her own spiritual wellbeing for this, for she thought that although there was no way in which such an action could be permitted, and she would be punished for it, nevertheless, better that she should go down to perdition so long as an enemy of God be removed thereby from the world.
Esther acted in the same way, as we find when she stated to Mordechai, “And if I perish, I perish (Esther 4:16).” That is, she was willing to risk even the destruction of her soul, God forbid, in that she transgressed with the intent of saving the Jewish people. (Takanat haShavin #5)