One of the names of Sefer Bamidbar is the Book of Numbers, as it opens with a census of Am Yisrael, and ends, in Parshat Pinchas, with another, 38 years later, when Israel are encamped opposite Jericho before entering the land.
Why is it so important to count us? Rashi tells us
Because they were dear to Him, He counted them often. When they left Egypt, He counted them (Exod. 12:37); when [many] fell because [of the sin] of the golden calf, He counted them to know the number of the survivors (Exod. 32:28); when He came to cause His Divine Presence to rest among them, He counted them. On the first of Nissan, the Mishkan was erected, and on the first of Iyar, He counted them.
This is similar to his commentary on the opening of Sefer Shemot
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]
We must ask two questions: firstly, we count a group of people when we do not know how many there are, just as a teacher counts his students on a trip to make sure no one has got lost. God is all-knowing, so why does he have to count his people?
The second question is since when is counting a sign of love? A census is a technical act. When a commander in the army counts his soldiers, it is not in an atmosphere of love or emotion.