Are there any rabbinic texts arguing that exile helped the Jewish people to survive centuries of threats? In a 'don't put all your eggs in one basket' sort of way?
Rabbi Oshaya said... The Holy One, Blessed be He, performed a charitable deed toward Israel in that He scattered them among the nations. [Sefaria adds: Had He exiled them to one place, they could have all been destroyed at once.] [Pesachim 87b]
וגם זה ירמוז שלא יגזרו עלינו בני עשו למחות את שמנו אבל יעשו רעות עם קצתנו בקצת הארצות שלהם מלך אחד מהם גוזר בארצו על ממוננו או על גופנו ומלך אחר מרחם במקומו ומציל הפלטים וכך אמרו בבראשית רבה (בראשית רבה ע״ו:ג׳) אם יבא עשו אל המחנה האחת והכהו אלו אחינו שבדרום והיה המחנה הנשאר לפלטה אלו אחינו שבגולה ראו כי גם לדורות תרמוז זאת הפרשה:
This also hints that the descendants of Esau will not be able to erase our name, but they will commit evils against some of us in some of their lands. One of their leaders will promulgate a decree in his land against our property or our persons, and another of their leaders in a different place will have compassion on us and harbor our survivors. Thus is it stated in B'reishis Rabba (76:3):
'If Esau shall come to one camp and strike it' – this refers to our brethren in the south [of Israel].1 'And the remaining camp will escape' – this refers to our brethren in the Diaspora.2
You see that this passage also hints to future generations.
1"This refers to the south of the Land of Israel" (Etz Yosef, ad loc.)
2The Midrash continues with Rabbi Hoshaya's comment that the Jews in the Diaspora, despite escaping this danger facing the Jews in the south of Israel, would fast and supplicate to support their beleaguered brethren in Israel ("א"ר הושעיה אף על פי שנשארו לפליטה מתענים היו עלינו בשני ובחמישי")
Perhaps not a direct answer to your question, but the דרשות הר"ן (דרשה א) explains that the builders of the tower of Babylon wanted to create a situation where everyone would be under one rule (of Nimrod), with the tower being his palace. G'd didn't want that, as then Jewish people would have no other country to run to, when being persecuted (as Abraham had to do when Nimrod persecuted him). Hence He made them speak different languages, so that they would not be able to live together and instead create different countries, so that the Jewish people would always find a safe haven.