* These answers represent basically the same meaning from several perspectives.
This phrase, originating from Niccolo Machiavelli's book "The Prince", is interpreted by some to mean doing anything whatsoever that is required to get the result you want, regardless of the methods used. It does not matter whether these methods are legal or illegal, fair or foul, kind or cruel, truth or lies, democratic or dictatorial, good or evil.
The phrase the end justifies the means refers to the morality of an action. It means that the morality of an action is based solely on the outcome of that action and not on the action itself. Example: Telling a lie that has no negative effect on anyone, and saves someone grief, is good. Killing someone to save others may also be morally justifiable.
A deontologist would say lying/killing is always bad. A consequentialist would say that it is acceptable if the outcome is positive. It can involve illegal activities and what some would consider immoral methods, but definitely is not based on that.
This refers to the idea that if you need a specific outcome, it doesn't matter how it is achieved as long as you get the desired result. For instance, if you need to pass a test in order to graduate (the end) you can justify cheating in order to pass the test (the means).
This is normally used to comment on the ethics or morality of a given action. By itself, it might be reprehensible. But as the only method to achieve a goal, it could be acceptable on a practical basis. A simple example would be knocking down historic buildings as a last resort to control rat populations. A more complex example would be World War II, which included bombing German and Japanese cities to reduce their munitions production.
It means that the benefits from something outweigh the harm done by the process. For example if somebody cured cancer, but had to kill 1 cancer patient to find the cure, they might say that curing cancer made the loss of 1 life to save many worth it. Of course, the family of the dead patient (and the legal authorities) might see the matter differently.