What is so terrible about David's desire to count his people? The king is only finding out what he possesses. The information is useful and very important for a ruler. From it he learns how many soldiers he can count on in war, how many taxes can be collected, and so on. It seems to us that the king has the right to know all this, since the king's authority is unlimited. Especially the authority of a king appointed by God.
But the unique feature of the king of Israel's position is that the people given to him actually belong to God. God counts them, multiplies them, and raises them. And the desire to push God aside, to deprive Him of authority even in thought, to count everything and possess everything, moving God somewhere higher up so that one can manage earthly things on one's own, is not only the desire of an anointed king, but of every person. At the same time, it is also the root of original sin: to possess everything oneself and declare oneself the owner of everything that appears to be one's own. But all this is only given into one's management. And the Owner Himself knows the times and seasons when He determines how wisely you are managing what has been entrusted to you.