Why do our sages say that exile is an expression of G-d’s righteousness?
In time to come, the manner in which the exile is in fact an expression of divine righteousness will become apparent. At the present, it is a matter of faith. Since the Sages teach us that "The Holy One, blessed be He, acted charitably towards His people by dispersing them amongst the nations of the world," we believe that this is so. This is not, however, comprehensible. For even after we have considered all the explanations offered for the exile (such as punishment for the people's sins, sifting scattered sparks of holiness, and so on), there are many ways are open to G-d; why, then, is there a need for the sufferings of exile?
In future time, by contrast, in place of faith, everyone will palpably see how the exile was an expression of G-d's righteousness.
In this sense we can understand the prophetic verse, “On that day you will say, ‘I shall thank You, G-d, for You were angry with me.’” This means that in future time, the good that lay hidden in the suffering of exile will be revealed: it will then be understood how it was specifically this suffering that enabled the Jewish people to be found worthy of the divine revelation of the time to come.
One reason why the exile is an expression of G-d’s charity is because the dispersion of the Jewish people allowed us to survive and thrive. When Jews in one part of the world were being oppressed, Jews in other locations were able to lend assistance and open up their own communities to welcome the Jews who were driven out of their lands. Also, through being dispersed throughout the world, the Jews were given many opportunities to elevate the world and bring G-dliness to each location. Moshiach will come when the entire world is permeated with G-dliness; thus, the dispersal of the Jewish people was necessary to achieve this goal.
Sources: Psachim 87b. Isaiah 12:1. Likutei Sichot vol. 20, p. 361; vol. 4, p. 1081