Why does Hashem count and name the stars in Heaven? This is mentioned in the first Rashi on Shemot, see below. I would like an explanation on this... Quote from Rashi: And these are the names of the sons of Israel: Although [God] counted them in their lifetime by their names (Gen. 46:8-27), He counted them again after their death, to let us know how precious they are [to Him], because they were likened to the stars, which He takes out [From beyond the horizon] and brings in by number and by name, as it is said: who takes out their host by number; all of them He calls by name (Isa. 40:26).
Radak explains in his commentary to Isaiah (40:26) and in his commentary to Psalms (157:4), that although there are a very many stars (he correctly suggests that the number of stars is much greater than those visible to the naked eye), God acted deliberately in creating them, and had a specific reason to create each one. This reason is the "name" of each star that God is always conscious of. He suggests that the point of the stars is astrological, while other Jewish thinkers may not have accepted the legitimacy of astrology. Regardless, his basic answer; that the names refer to God's purpose for them and reason to create them, need not be challenged.
The metaphor in Rashi seems to be that just as God acts with deliberation and care with the cosmos; creating each star for a purpose and moving it to specific places in the universe; not allowing it to wander randomly, so too does God care about each of the Jewish people.