Would there be a specific word or phrase that basically means a good person that does something bad for the good of the people?
I don't really know if that makes sense to anyone but me, but I would definitely appreciate some help!
Self-denial. It refers to altruistic abstinence. According to Wikipedia,
the willingness to forgo personal pleasures or undergo personal trials in the pursuit of the increased good of another.
Or if Self-denial doesn't suit you, you can use Self-sacrifice. According to Merriam-Webster,
the act of giving up something that you want to have or keep in order to help someone else
If one could think of this situation as analogous to parent-child relationships, then one could speak of tough love:
Tough love is an expression used when someone treats another person harshly or sternly with the intent to help them in the long run.
It certainly has been used in social/political contexts:
a well-intentionned blunderer
blunderer - someone who makes mistakes because of incompetence.
well-intentionned - Wanting to have good effects, but sometimes having bad effects that were not expected.
If you want to convey an idea of stupidity, then a well-intentionned goofball.
The person you described believes that
the ends justify the means.
A couple of commenters mentioned altruism, which reminded me of another ethical doctrine that is actually a better fit: utilitarianism, as defined in classic philosophy. According to the most rigid definition of the word, a utilitarian is a person who does whatever produces the most good for the most people, even if his actions cause considerable harm to a smaller number of persons or to an individual.
First, a possible candidate that I decide against.
An obvious possibility is “Machiavellian” (named after Machiavelli). Unfortunately [for the purpose here], Machiavelli is generally regarded as ethically dubious. He (thought and) wrote about how to rule well (read “effectively”). His view was that, as a practical observation, everything was an ethical dilemma — that it is normal (and possibly that it is true in principle) that particular desirable outcomes would generally (or always) require doing things that were morally wrong, in and of themselves. (I think that he did not actually argue, case by case, that the wrong was justified, but that this was always implied by the numbers of people helped (being the whole society).)
When studying Machiavelli, it is difficult to disagree with his cause-and-effect accounts leading backwards from good ends to bad means (which is not to imply that his logic indeed is sound). Taking a step back, though… intuition says that the picture he draws, in which a ruler always has to behave immorally, can not be the only possible picture.
I do not think that there is a single word (nor, offhand, a ready phrase) for a person as described, unless you can indeed say something like, “(S)he was a real Robin Hood.” [nod to Julie Carter], or something like that.
If you do construct a phrase, I would expect it to have the term “ethical dilemma” in it… although that would make for a fairly clumsy phrase, I am thinking.
Another dubious possibility is “anti-hero”; unfortunately, the darkness in that picture is immediately about the person themself, I think (?) — as opposed to what they do being necessarily immediately morally wrong (assuming that hurting bad people is not).
Now that I am thinking about it… an example might be useful, as… in situations in which it is ethically right to do something that is immediately bad, on behalf of a whole people group… this suggests a situation in which it is obvious that something should be done, that would otherwise be simply wrong, such as overthrowing a terrible leader using military force (or assassination).
In that case, there might be obvious terms such as “revolutionary”. Robin Hood was such; the reason why what he did was good was that the rulership was evil.
Are you talking about a peculiar and particular situation that represents an ethical dilemma (perhaps with there being a need for someone to step up and do the pertinent deed)? In this case, the person would largely be a hero, for having the courage to do something that would (presumably) be difficult. There would also be plenty of people to say that what (s)he did was morally wrong.
Suggestions: reverse altruist or anti-altruist.
I don't think there is a word for what you describe.
But I would suggest a created phrase for it, called a "reverse altruist" which I think comes close to capturing your intent.