שאו את־ראש בני־ישראל למשפחתם לבית אבתם במספר שמות כל־זכר לגלגלתם׃ מבן עעשרים שנה ומעלה כל־יצא צבא בישראל תפקדו אתם לצבאתם אתה ואהרון׃
The Ramban explains תפקדו (usually translated as counting in this paseuk) along the lines of the verse וה׳ פקד את שרה כאשר אמר (And Hashem remembered Sarah as he had said). He also relates the idea to a פקדון (a deposit) because the shomer (who holds the deposit) watches over and directs the deposit. Hence, the idea of a census is that each person in Am Yisrael should be remembered individually. How? במספר שמות (usually translated "by the count of their names"). The Ramban relates the word מספר to the verb לספר (to tell, as in a story) and explains that when each person deposited his half shekel (Shemot 30:13) he also told the census taker his name.
The Emek Davar interprets similarly, but does not require the half-shekel since it is not stated in the commandment for this census. Instead, he explains that במספר שמות means that each person counted brought a slip of paper with his name on it, and put it into a box to have that counted. Afterwards, the leaders of the tribes each came with their own box and sifted through the names to find the names for their own tribe. (All except for the tribe of Naftali who didn't need to sift. Since he came last, all the remaining names were his, as indicated by the lack of a ל at the beginning of Bemidbar 1:42.)
The Ramban further explores the reason why David HaMelech was punished for his own census. He rejets the idea that it was because David didn't use shekels, since surely he knew the halacha, and if not, Yoav (his general) did. (And Yoav says so in Divrei HaYamim 1 21:3.) Rather, he advances other reasons.
One reason was that David counted for no reason other than his own glory. In this parsha, had it not been for the sin of the spies, this census is the one that would have been used to divide the land after Am Yisrael entered the land just a few days later.
Another reason: David wanted to count men from the age of 13 and up. The Ramban syas that the verse (Shemot 30:14) did not allow the Jews to be counted except from the age of 20 and up. (The punishment of a plague applying to an error here too.)
The Ramban says further that Hashem does not want all of israel counted together in one number, because we are compared to the stars of the heavens and the sand of the sea, which cannot be counted.
It seems to me that these last two reasons are related. That Hashem wanted a count only from 20 to 60 so that the exact number of adult males would not be known exactly, and only a portion of the number would be. Furthermore, I have heard from my teachers that something whose count is known exactly cannot be a recipient of blessing, so it seems to me that the purpose of a plague killing people was a way to restore the nation to its previously uncounted state and make it worthy of blessing. (Though Shmuel 2 24:15 mentions that 70,000 men died, surely nobody knew the exact count besides Hashem, and the Navi who later recorded sefer Shmuel.)
May you all be blessed with the blesings of an uncountable people, and with the blessings that flow from the Kedusha of Eretz Yisrael. Amen.