There’s a lot to do
The Empire is indeed a totalitarian state. It needs enormous numbers of stormtroopers to instill fear, to put down rebellions on the worlds it rules, and so forth.
Conducting oppression at the galactic scale is a difficult business. Even with advanced weapons and relatively fast transportation, considerable numbers of troops are needed to deal with the thousands of situations that might arise at one time (and a “situation” could be the equivalent of a full-scale catastrophe on a planetary scale). Coruscant, the capital of the galaxy, by itself has 1,000,000,000,000 (one trillion) people1, though most planets are significantly more sparsely populated. They are in some ways less a regular army than a fusion of army and police force (again, reinforcing the “police state” motif). Their purpose is to safeguard the Empire’s interests through fear and violence:
Stormtroopers are stationed on strategic worlds throughout the galaxy.
On planets like Lothal, Tatooine, and Coruscant, they serve a variety
of functions. They guard mining operations, factories, and commercial
interests important to the Empire. They maintain societal order and
monitor politically sensitive areas—stamping out all signs of
rebellion.
Ultimate Star Wars
The number of stormtroopers also reinforces their expendability:
Stormtroopers have replaced the clone armies of the Republic as
expendable soldiers. Their endless numbers serve across the
galaxy, enforcing the Emperor’s will.
Ultimate Star Wars
As a side note, there might not be quite as many stormtroopers as one might imagine. According to the canon video game Star Wars: Uprising, the Empire had 25,000 Star Destroyers. There were about 45,000 soldiers per Star Destroyer2, which comes to about 1.1 billion stormtroopers on Star Destroyers. An incredible number by modern standards, certainly, but still a fraction of the population of Coruscant alone. In all likelihood, considerable numbers of stormtroopers were also present as local garrisons on planets, so the true size of the Imperial forces is difficult to estimate. Nonetheless, speed (allowing the rapid deployment of troops to problem areas) and advanced technology are likely the Empire’s main weapons in combat, not having enough soldiers to maintain Earth-size armies on every planet.
1: Star Wars: Absolutely Everything You Need to Know
2: Ultimate Star Wars, p. 291