“Break a leg” comes from the First World War, when, before flying, German airmen wished each other a “broken neck and a broken leg.”
Considering the dangers of combat with primitive aircraft, this was preferable to losing your life, which was all too common.
After the war, the phrase was picked up by actors in the German theater.
It was eventually adopted by the British and American stages, where it was abbreviated to “break a leg.”
Actors often say “break a leg” when wishing each other good luck.