This is, of course, a matter of personal opinion. There is no way to objectively determine when the results of an experiment have been worth the negative effects of that experiment. My own view is that the outcomes of this experiment did not justify the means used by the people who were acting as guards.
There are at least two ways to argue that the ends did not justify the means. First, we can argue that the ends were not very important in and of themselves. We can argue that the experiment really did not cause the researchers to learn much that was of value. The researchers thought that they had learned that prison conditions dehumanize both the prisoners and those who are placed in positions of authority. However, it is not at all clear that this was truly proven. It is hard to prove that the people involved did not already have personalities that predisposed them to act as they did. It is also hard to know whether true prison conditions have the same psychological impact as the conditions created in the experiment.
But even if we stipulate that the ends were important, we can still argue that they did not justify the means used. I would argue that any experiment that forces human beings to suffer cannot be justified. It is impossible, in my mind, to argue that it is right to intentionally cause suffering in one group of people in the hope of learning something that might help improve the lives of another group of people. It is not ethical, I would argue, to use experimental subjects simply as means to an end.
So, I would say that the ends did not justify the means. I would assert that there are no ends that truly justify conducting experiments in which you intentionally inflict harm on human beings.