Yosef's Part in the Sale and Rebbi Yishmael's Atonement
Teshuvah
According to the Ari (Rav Yitzchok Luria), Yosef himself brought about the sale by his brothers, and everything that happened to him as a result. By publicizing his dreams of rulership and by speaking lashon hara about his brothers, Yosef brought upon himself all of his misfortune. Rebbi Yishmael was the gilgul (reincarnation) of Yosef HaTzaddik. Just as Yosef had the beauty of Adam and was handsome, so was Rebbi Yishmael, and his death was an atonement for the sin of Yosef himself. This was not the only reason he had to die so gruesome a death, but it was the main reason.
Source: Ari, Sha'ar HaGilgulim, Hakdama 34