“Ha-Shem fits the punishment to the crime. Korach opened his mouth to utter rebellion and dissension; so ‘the earth opened her mouth and swallowed him’ .” 
This Hasidic teaching by Rabbi Shalom Roke’ach, the first Belzer Rebbe, is perfectly in line with older teachings about the principle of “midah k’neged midah” – “measure for measure” – as the criteria for the Divine response to our actions.  It especially parallels Rabbi Hama ben Hanina’s teaching about the “karmic” reason for the drowning of the Egyptian army. 
Yet, another Hasidic teacher, Rabbi Shneur Zalman of Liady, the first Habad/Lubavitcher Rebbe, wrote: “And though it’s a person possessed of free choice cursing [you], or hitting [you], or causing damage to [your] money, and therefore guilty according to the laws of man and the laws of Heaven for having chosen evil, nevertheless, as regards the person harmed – this was already decreed from Heaven, and ‘The Omnipresent [המקום] has many deputies ’.”  He uses an example from TaNaCH: David is cursed by Shimei. His bodyguard would have harmed or killed Shimei, but David restrains him, saying, “For Ha-Shem told him, ‘Curse’.” 
The Rebbe’s teaching: G-d is actually creating the evildoer and keeping him/her alive at the very moment that he/she is doing wrong. G-d, then, was creating Korach and keeping him alive even at the very moment that he was confronting and challenging Mosheh. What’s more, the evil that’s done – by Korach, in the present example – is done at the decree of G-d! Korach is one of G-d’s “deputies” [שלוחים — “sh’lu’chim”], whether he knows it or not.
Our first reaction could certainly be bewilderment. It seems unfair. But the Rebbe isn’t teaching a theoretical course in “Moral Theology.” He’s urging us to personally recognize G-d’s Will in all things, because G-d is Present in all things (and events). When we accept G-d’s Will, we simultaneously find G-d’s Presence. G-d’s Will is G-d’s Presence. There are no divisions or separations in G-d
Finding G-d’s Presence in things or events, we find G-d in ourselves, too. Why? Because the whole change is really occurring in our own perception; in our own “thinking,” as it were. But thinking about the idea or concept of G-d’s continuous Presence in things is still only the middle stage of the process. The final stage goes beyond the intellect.
When we find G-d’s Presence, Peace fills us spontaneously.
It’s the essence of what I try to give in spiritual counseling.
Bad things happen to all of us. We can easily respond with anger or sadness, especially when the wrong done to us appears to be “unfair” or “unjustified,” as it so often does. It’s precisely at those moments that our service of G-d – our harmonious relationship with G-d — requires our joyful remembrance of G-d’s Presence: עבדו את ה” בשמחה — “Serve G-d with joy.” 
As Rabbi Joseph Gelberman, z”l, wrote:
“Do not feel sad or melancholic. I have certainly experienced the cruelty and hardness of the world, beginning with the Nazi Holocaust in which I lost most of my family. I still remember that G-d said, כי טוב — ‘Ki Tov’ — ‘It is good‘ ! …I repeat it often to myself. I distinguish between happiness and joy. And although I often am not happy, I am always joyous.” 
Korach would be Kohen Gadol — High Priest — leading all Creation in worship. Yet, he wouldn’t accept G-d’s Will in choosing Mosheh and Aharon over him. He chose his own will over G-d’s. His sincere but muddled desire for holiness led him to envy, to anger and finally, to destruction. The “world” — his own will; his own “yetzer” — “swallowed” him.
Even so, he was G-d’s “deputy.”
We can learn from him to regard all that happens to us as being from G-d.
Let’s honor Korach, then. In his own way, he becomes our teacher, too.