The idea most likely come from superstitious belief. Superstitious belief refers to a widely held but irrational belief in supernatural influences which lead to either good or bad outcome. Some superstitions originated from traditions, stories, folklore, myth, legends, etc. The belief that whistling on board brings bad luck is one of the sailors' superstitions.