Boric acid don't kill the ants, it kills their gut protozoans that break down cellulosic material in order for it to be able to digest and use it as food, eventually starving the host ant. The fact that ants share it with their nest-mates means it's a targeted attack. The not-yet sick ants share the borates with their buddies,and sick ants are often cannibalized by their nest-mates, and over the course of a week the net effect on a nest is profound.
But borates also kill plants, so use very sparingly in a lawn application.
Toxicity to humans and other mammals is quite low- boric acid and other borates are often used in soaps, detergents, cosmetics etc.