My understanding of it is...
"The edge of a stage was marked with a line known as the "leg" or "leg line". Beyond this point one could be seen by the audience and those not required to be on stage had to remain back stage and not cross (break) the "leg line". In a time when performers would queue for an opportunity to perform, and were only paid if they did perform, to "break a leg" meant the performer crossed the line onto the stage and would therefore get paid. So to tell a performer to "break a leg" was to wish them the luck to have the opportunity to perform and get paid. The sentiment remains the same today, "good luck, give a good performance".