Another law of magic is “everything happens for a reason” — there is no such thing as randomness or happenstance. This is so-called teleological reasoning, which assumes intentions and goals behind even evidently purposeless entities like hurricanes. As social creatures, we may be biologically tuned to seek evidence of intentionality in the world, so that we can combat or collaborate with whoever did what’s been done. When lacking a visible author, we end up crediting an invisible one — God, karma, destiny, whatever.

This illusion, too, turns out to be psychologically useful. In research led by the psychologist Laura Kray of the University of California, Berkeley, subjects reflected on a turning point in their lives. The more they felt the turning point to have been fated, the more they believed, “It made me who I am today” and, “It gave meaning to my life.” Belief in destiny helps render your life a coherent narrative, which infuses your goals with a greater sense of purpose. This works even when those turning points are harmful: in a study led by the psychologist Kenneth Pargament of Bowling Green State University, students who saw a negative event as “part of God’s plan” showed more growth in its aftermath. They became more open to new perspectives, more intimate in their relationships and more persistent in overcoming challenges.

There are similar laws that govern other popular superstitions, including the belief that objects can carry the “essences” of previous owners (which explains why you might want to own a pen once used by a favorite writer); the belief that symbolic objects can summon what they represent (which explains why you’re scared to cut up a photograph of your mother); and the attribution of consciousness to inanimate objects (which explains why you yell at the laptop that deleted your files). In various ways they all emerge from basic habits of mind, and they all add structure and meaning to a chaotic and absurd universe.

Which isn’t to say magical thinking has no downside. At its worst, it can lead to obsession, fatalism or psychosis. But without it, the existential angst of realizing we’re just impermanent clusters of molecules with no ultimate purpose would overwhelm us.