"וְהָיָה מִסְפַּר בְּנֵי יִשְׂרָאֵל כְּחוֹל הַיָּם אֲשֶׁר לֹא יִמַּד וְלֹא יִסָּפֵר"
"And the number of the children of Israel shall be as the sand of the sea, which cannot be measured nor counted" (Hosea 2:1).
Rabbi Yonatan asked the following question: if it says that the Jewish people cannot be counted, how is even possible to speak of "the number of the children of Israel"?
His answer: When they perform God's will - then they will be uncountable, like the sand of the sea. But if they fail to perform God's will, then there will be a finite "number of the children of Israel."
The Maggid of Dubno explained this Midrash with the following parable:
The Argument of the Two Boys
In a certain town were two small boys. Each one claimed that his father was richer.
"There is no one in town as rich as my dad," the first boy said. "His pockets are full of coins - dimes and quarters and nickels. Whenever he walks by, you can hear all of his coins jangling away!"
"It's true, your father has a lot of coins in his pockets," the second boy responded. " But if you ever see my dad pay for something, he opens up his wallet and you can see that it is full of dollar bills. And even if there are not as many bills as your father's coins, each one is worth a lot more than all of those dimes and nickels!"
So too, with the Jewish people. When they fail to fulfill God's will, they have a finite measure, and can be counted like any other people. They are like a pocket of coins, easily measured and counted.
But when they keep God's will, then they are beyond all regular calculations. Each one is a precious jewel. Even if they are counted, their true worth cannot be determined. Like valuable banknotes, each one is worth many, many coins....
(Adapted from Mishlei Ya'akov, pp. 304-305)