How is it possible, asks the Sforno (Bereishis 37, 18), that the Shevatim, whose greatness is apparent in the fact that their names were engraved in the stones of the Kohein Gadol to be worn as a remembrance before Hashem, conspired to kill (or sell) their own brother? He answers that they pictured Yosef as a conniver who wished to wipe them out of this world or the next world, and possibly both worlds. In such a scenario, the Torah dictates, "If a person comes to kill you, you should kill him first." Hence, in the eyes of the Shevatim, in strict adherence to halacha, Yosef deserved to be put to death.
This explanation puts the whole story of the sale of Yosef in another light. The Shevatim convened a court and only after the guilty verdict did they devise a plan to get rid of Yosef. Yet, if this was the case, what did the brothers do wrong? Rav Wolbe (Shiurei Chumash) says the answer can be found a few pasukim earlier (ibid. 12). "And his brothers went to pasture their father's sheep in Shechem." Rashi cites Chazal who infer from the dots the Torah placed on top of one of the words ("es") that their true intention was not to bring their sheep to pasture, but rather, to bring themselves to "pasture" i.e. to tend to their own personal interests. We must bear in mind that the Torah is describing some of the greatest people who ever walked this Earth. However, like a seismograph which picks up even the slightest tremor in the most remote place, so too, the Torah picks up even the slightest flaw in a person's middos. Personal feelings got involved on some level, which was enough to set off a chain of events that would alter history forever.
Rav Wolbe adds that when studying the stories mentioned in the Torah one must take note of two different storylines that are taking place, i.e. the overt story and the covert story. In the above narrative, everything seems straightforward. Based on Yosef's dreams and other telltale signs, the brothers concluded that he was to be dealt with as one should with a would-be murderer. However, there was also the covert side of the story, and that was laced with egocentric feelings that brought them to jealousy and hatred, albeit subconsciously.
A person can be likened to a coal mine. Just as a mine is made up of numerous different strata, so too, a person is made up of numerous different layers. He is cognizant of some of these layers, while others he is aware of only subconsciously. Had the Torah not revealed to us the brothers' underlying impetus to kill Yosef, there would be no way to know their subconscious intentions, for it could very well be that they themselves were unaware of these feelings.
Middos are a very powerful player in determining the way a person conducts himself. Very often a course of action is taken based upon "negius" - a personal connection in one way or another. It could very well be that we are unaware of these feelings. However, sometimes if we were to take a minute to reevaluate the situation, we might be surprised to find that our 'altruistic' actions were in truth induced by self-aggrandizement. This is one of the lessons to be learned from the sale of Yosef.