Answered by Shaykh Faraz Rabbani
Question: In reference to your statement, “Our scholars said that the one who takes a glass of water to drink from, and then brings to mind that it is wine, it is unlawful for him to drink it,” if I take a glass of wine and then bring to my mind that it is water, then is it lawful for me to drink it?
Answer: Walaikum assalam wa rahmatullah,
I pray this finds you in the best of health and spirits. No, it is not permissible to drink wine–nor do anything else impermissible–with a “good intention.”
Good intentions may make a permitted action worthy of reward; bad intentions may make even a good action worthy of reproach or even sin.
However, good intentions do not make disobedience permissible, as the scholars explain. [Ibn Nujaym/Hamawi, Hashiyat al-Ashbah]
A “good intention” is an intention that is (1) to seek the pleasure of Allah, doing so in (2) a manner pleasing to Allah.