Isn’t it the funk that grows after you sweat that actually stinks?
I always thought deodorant was like skin-friendly lysol, it keeps bacteria from growing on you, blocks off some amount of the sweat since it’s semi-permeable, and smells manly or womanly so you can keep people from getting confused when they snuggle up with your pits.
I guess the other portion is that it has to stay in place, and be fairly easy to apply, hence the gooey bar form.