In last week's haftarah, we read about how Yael killed Sisera, the enemy general. The Gemara in Horiyos (10b) says that Yael slept with Sisera seven times before killing him, and refers to this as a sin with a good intent - aveirah li-shmah. This is quite an astounding statement!
The Rashbash (R. Shlomo ben Shimon [ben Tzemah] Duran) explains this in his Iggeres Milhemes Mitzvah as follows:
This is an allegory and the meaning is that she gave him milk to drink to strengthen his sperm as mil does... The combination of such foods with the exhaustion of travel and the sight of a beautiful woman will lead to an emission. In his thoughts, he had relations with her and that is to what this passage refers. The intent of this righteous woman was to weaken him [so that she could kill him]. This is called a "sin with a good intent" because she allowed him to stare at her so that he would have a discharge and be weakened. This is the meaning of this passage and not that this righteous woman literally slept with this wicked man.