When you have sanity, you're mentally healthy and not acting crazy. Sanity is a word for having a healthy state of mind — people with sanity don't have any loose marbles.
Sanity (from Latin: sānitās) refers to the soundness, rationality, and health of the human mind, as opposed to insanity. A person is sane if they are rational.