The opening Rashi in Shemos says וְאֵלֶּה שְׁמוֹת בְּנֵי יִשְׂרָאֵל. אַף עַל פִּי שֶׁמְּנָאָן בְּחַיֵּיהֶם בִּשְׁמוֹתָם, חָזַר וּמְנָאָם בְּמִיתָתָם, לְהוֹדִיעַ חִבָּתָם, שֶׁנִּמְשְׁלוּ לְכוֹכָבִים, שֶׁמּוֹצִיאָם וּמַכְנִיסָם בְּמִסְפַּר וּבִשְׁמוֹתָם (שמות רבה), שֶׁנֶּ' "הַמּוֹצִיא בְמִסְפָּר צְבָאָם לְכֻלָּם בְּשֵׁם יִקְרָא Why are Klal Yisrael compared to stars? What does the mashal add, anything can be counted? How does counting show the precious they are?
Rashi quotes the possuk in Yishayeh (40:26) המוציא במספר צבאם לכלם בשם יקרא. There is another, similar possuk in Tehillim (147:4) מונה מספר לכוכבים לכולם שמות יקרא. Why the switch from singular, בשם to שמות, plural? The Midrash in Vakhal (48:2) says כיצד יתקיימו שני כתובים אלו אלא כשהקב"ה מבקש לקרותם כאחד הוא קורא לכלם שם אחד וכשהוא קורא לכל אחד ואחד בשמו הוא קורא אותו מיכאל גבריאל לכך נאמר לכלם שמות יקרא. The meaing of this Midrash is elaborated on by Rav Tzaddok in Sichas Malachay Hasharas and by Rav Kook in Midbar Shor #14. They explain it a bit differently but the germane of the idea is the same. The idea is that the name of a subject is an identification of its true identity, its purpose and importance. The possuk which says בשם is talking about the grandeur of all of nature having one unified purpose and how inspiring that is. There the focus is on the unified goal. בשם יקרא, there is one unified goal and purpose to everything. The possuk in Tehillim is focused on the individual goal of every individual star. The possuk is focusing on the individual importance of everything. That is בשמות, every one has their own mission to fulfill, their are various missions for individual souls.
The counting of the shevatim is compared to the names an counting of the stars. Just as a name indicates the mission and importance of the individual, so too the act of counting. Counting means that there is something to be counted for, there is a purpose, a mission.
As the golus of Mitzraim was starting it would seem that in the darkness of the golus the importance of Klal Yisrael would be lost. They would cease to have an independent existence and would be subsumed under the mission of the Egyptians. That is what the mashal of stars comes to tell us. Just as stars are very far off from the earth and their impact is not felt very much, nonetheless they give off light. The Gemarah Pesachim (2a) discusses if the light of stars is considered light and the conclusion is that it is. What is the debate? Since the light of stars does not illuminate like the moon and suns, one may say that is not defined as light. However, the conclusion is that since stars have their own innate light that is called light. Similarly, even in a dark golus where the power of Klal Yisrael to illuminate is diminished, they still retain a glimmer of light. The connection to Hashem still exists and that light is what allows Klal Yisrael to survive (from Rav Moshe Shapira.)
The Rebbe adds (Likutay Sichos volume 6) מנאן בשמותם, in their names, referring to the neshama of a person in a bodily form that is called a name, one has to awaken the מנין, the unifying count, the holy source, that unites all souls. It is that connection to one's source that gives one the ability to overcome the boundaries of one's body, Egypt, and the golus. The ability to be light, to feel one's neshama, to be part of a collective mission, is what turns golus into geulah.