Salt is a classic and insanely useful ingredient, and has been for millennia. It has two very important properties for food – it makes things delicious, and is a desiccant. It draws water out of things, which kills many microorganisms (even small salt grains are quite big for microorganisms, so the osmosis has a massive effect).
It's important to remember that sugar has these properties too. And while we like to think that modern food preservation has moved past the old techniques, supply chains are much longer, and for processed food, you want all the extra time you can manage.
You can tell sugar is a desiccant by just adding sugar to something like strawberries and waiting (or, if you're me, being so insecure about your food science knowledge that you double check online even after seeing a syrup form – don't worry, wikipedia confirms). And as nice as slices of strawberries can be, imagine the indulgence, before modern candy bars, of slices of strawberry, cut thin, coated in a dusting of sugar and left to dry in the sun. A pure delight.
It's hard to blame food manufacturers for adding it to so much.