The original Murphy's Law reads: "If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it." It was then a principle of defensive design. For example, you don't make a two-pin plug symmetrical and then label it "THIS WAY UP"; if it matters which way it is plugged in, then you make the design asymmetrical so it can't be plugged in wrong.
Edward A. Murphy, Jr. was one of the engineers on the rocket-sled experiments that were done by the U.S. Air Force in 1949 to test human acceleration tolerances (USAF project MX981). One experiment involved a set of 16 accelerometers mounted to different parts of the subject's body. There were two ways each sensor could be glued to its mount, and somebody methodically installed all 16 the wrong way around. Murphy then made the original form of his pronouncement, which the test subject (Major John Paul Stapp) quoted at a news conference a few days later.
Within months "Murphy's Law" had spread to various technical cultures connected to aerospace engineering. Before too many years had gone by variants had passed into the popular imagination, changing as they went. Most of these are variants on "If anything can go wrong, it will."; this is sometimes referred to as Finagles law. These mutant versions demonstrates Murphy's Law acting on itself!