Origin: "Break a leg" is sourced in superstition. It is a wish of good luck, but the words wish just the opposite.
It was once common for people to believe in Sprites. Sprites are actually spirits or ghosts that were believed to enjoy wreaking havoc and causing trouble. If the Sprites heard you ask for something, they were reputed to try to make the opposite happen.
Telling someone to "break a leg" is an attempt to outsmart the Sprites and in fact make something good happen. Sort of a medieval reverse psychology.
Of course it has became a popular wish of luck for theater performers.