David sought to know of his military strength by numbering the warriors in Israel, but in so doing, he momentarily did not rely upon the Lord.
Therefore, the Lord sent a prophet to David, asking him to choose between three punishments. Note the first one,
So Gad came to David and told him; and he said to him, “Shall seven years of famine come to you in your land? Or shall you flee three months before your enemies, while they pursue you? Or shall there be three days’ plague in your land? Now consider and see what answer I should take back to Him who sent me” (2 Samuel 24.13).
David had to choose between seven years of famine, three months fleeing from his enemies, or three days of a plague. All these numbers have some significance, because we often see “three,” in the Scriptures, and so we know that seven here had spiritual significance.
Seven years of famine would wipe out the land and a good portion of the people of Israel, showing David how quickly the Lord could annihilate Israel, because Israel’s strength was not in her numbers, but in the Lord.