Decomposition, mold/bacteria/fungi/yeast growth requires water. Sugar is food, but food doesn't help if there's no water - which is why table sugar has an unlimited shelf life. Same applies to soap that's not wet. When soap IS wet, then it's a solution with a pH too high to support any kind of mold growth. So it's next to impossible to have problems on the bars themselves.
The potential issue comes when enough water is added to dilute the soap enough for the critters to survive. Think the perpetual puddle in the bottom of the soap dish that your properly-designed holder suspends the soap above. Every time you reach for that soap with wet hands, you drip a bit into the puddle, but not too much soap gets in there. THAT is where you can sometimes see mold or bacteria growth.
Sugar and salt as a means of preserving foods primarily act as drying agents. High concentrations of either around a food first draw moisture out of it via osmotic pressure - essentially drying the food itself. Secondarily, as long as the salt/sugar concentration stays high enough around the food, any subsequent bacteria or yeasts will themselves be dehydrated to death by that same osmotic pressure which protects the food long-term.