This rule (well, superstition) dates back as far as the 17th century where stage crew were often hired from ships in port. They would communicate using whistles and the danger was, if you whistled on stage, they might take it as a scenery cue and you might find a backdrop smacking you hard on the head.
The theatre is full of superstition, probably the most famous being the ban on using the name Macbeth or even quoting from the play within a theatre. I can’t find any genuine reason why this became such a ‘thing’ but, if you do fall foul of this rule you must leave the room, spit on the floor, turn round three times and then knock and ask for readmittance.
Here's my favourite term - "Is the Ghost walking?" which means "Are we being paid today?"