How is using a transformer for isolation safer than directly connecting to the power grid?
Without a transformer the live wire is live relative to ground.
If you are at "ground" potential then touching the live wire makes you part of the return path.



{This image taken from an excellent discussion here

With a transformer the output voltage is not referenced to ground - see diagram (a) below. There is no "return path" so you could (stupidly) safely touch the "live " conductor and ground and not received a shock.



From The Electricians Guide

I say "stupidly" as, while this arrangement is safer it is not safe unconditionally. This is because, if there is leakage or hard connection from the other side of the transformer to ground then there may still be a return path - as shown in (b) above. In the diagram the return path is shown as either capacitive or direct. If the coupling is capacitive then you may feel a "tickle" or somewhat mild "bite" from the live conductor. If the other conductor is grounded then you are back to the original transformlerless situation. (Capacitive coupling may occur when an appliance body is connected to a conductor but there is no direct connection from body to ground. The body to ground proximity forms a capacitor.) 

SO a transformer makes things safer by providing isolation relative to ground. Murphy / circumstance will work to defeat this isoation.

This is why, ideally, an isolating transformer should be used to protect only one item of equipment at a time. With one item a fault in the equipment will propbably not produce a dangerous situation. The transformer has done its job. BUT with N items of equipment - if one has a fault from neutral to case or is wired wrongly this may defeat the transformer such that a second faulty device may then present a hazard to the user.  In figure (b) above, the first faulty device provides the link at bottom and the second provides the link at top.



Similarly: