Sanity is an attribute on your character. It starts out at 0, which is the healthiest level possible.
Whenever increased, you have a chance to enter Unsteady status, inflicting a wide variety of disorienting negative effects will be inflicted on the character, such as sleep, dim, confusion, and fear. Successfully being struck by insanity while Unsteady will upgrade its state to Insane, and further to Paranoia if stricken again once more insanity.
Having a high sanity level only increases your susceptibility to insanity-inducing effects, and otherwise has no lasting ill effects. However, it is suggested to recover your sanity as you have little to no control over your character once driven insane.
Eating human corpses, and some certain monster corpses increases sanity. Note that in the case of human corpses, you will not be inflicted by insanity if you have the "You are charmed by the taste of human flesh" mutation, and have a chance to gain the mutation upon eating human corpses.
Some monsters can also use the Eye of Insanity special action, which can cause insanity. Hiring a prostitute in Derphy ("I'll buy you") will increase your sanity, but prostituting yourself to drunken NPCs ("Interested in a lil' tail tonight?") will not.
You naturally recover sanity at an extremely low rate. The feat you get from the secret treasure of Jure increases the natural recovery rate.
Using a statue of Jure reduces Sanity by 500, and using a unicorn horn reduces it by 50. Eating a little sister's lunch will reduce it by 30, and eating a Hermit Crab or Giant/Killer Squirrel corpse will reduce it by 20 ("Eating this brings you inner peace"). The hotspring in Larna will also reduce Sanity by 1 for every tile walked through. 0 is the minimum and the healthiest possible value.
Flavor text will be displayed when an NPC or player is having Unsteady, Insane, or Paranoia states.
"So I have to kill"
"Forgive me! Forgive me!"
<name> starts to take <his/her> cloths off
Note that the game misuses the term "sanity", as sanity is actually a good thing in reality, and "insanity" would be unhealthy to have increase.