It's also used in stain-hiding paints, and it's useful in wood finishing if you need a barrier layer between two incompatible finishes (which is why it works in stain-hiding paints and primers).
The shellac flakes are usually dissolved in alcohol, it doesn't "cure" with a chemical change as with many resin based finishes. It is simply what is left behind when the carrier solvent evaporates. And, as noted, it's not poisonous (once the solvent is gone), so it can be used on surfaces kids might chew, like cribs or cradles or surfaces subject to food contact.
Very handy stuff.