David's sin was pride and ambition in counting the people so that he could glory in the size of his nation and army, its power and defenses.
He put his faith in the size of his army rather than God's ability to protect them regardless of their number.