Some believe morally wrong actions are sometimes necessary to achieve morally right outcomes. But, you can never do something that is wrong in order to achieve something that is good. Wrong is wrong. Always. A good outcome doesn't change that. The rightness or wrongness of an action is found in the action itself, not in its outcome.
The “end justifies the means” kind of thinking is really nothing more than delusional self-rationalization for unethical, immoral, and illegal behavior. In other words, it’s a way to get what one wants while feeling morally superior to others who disagree. It’s a way to philosophically justify bad behavior.
Cheating to pass a test, lying to get elected, stealing from the rich to give to the poor, destroying property to make a point is wrong. Period.