Magnesium hydroxide is a naturally occurring mineral, called brucite. It is made in industrial scale by crystallising it out of seawater by adding calcium hydroxide.
Magnesium hydroxide is our magic ingredient in our deodorants as it alters the pH of your skin. The bacteria which munch on our skin excretions like sebum and sweat and create the BO smell through their waste products can not survive in that environment and as a result, you don't smell- even if you sweat.
It won't irritate your skin like baking soda will either! Commonly found in antacids.