Safeties work to prevent discharge.
Most of the time. Like all things mechanical though, gun mechanisms do on occasion fail without warning. I once had a '98 Mauser fire as I disengaged the safety...
I'd pulled the trigger, then realised that the safety was on. Not noticing that the trigger hadn't returned forward, I flipped the safety off and boom. It was pointing downrange, but was no longer on my shoulder when it went off and the bullet went over the backstop. In this case it would have been safer
not to have engaged the safety; the rifle would have fired normally and cycling the bolt for the subsequent round would not have set the striker, alerting me that something was wrong.
For most of my shooting (hunting, plinking, target shooting), I'm able keep the chamber empty when I'm not firing. If a gun leaves my hands, the action is opened whenever practical so I and others can clearly see that it's not able to fire.
I've found that more often than not - especially with younger and/or less experienced shooters - manual safetys lull some into a false sense of security where they think they can be lax on important safety aspects of gun handling.