Here's a breakdown of the origin:
* さよう (sayō) is a contraction of さようなら (sayō nara) meaning "if it is so".
* なら (nara) means "then".
While "sayō nara" was originally a polite phrase used in formal situations, it eventually became shortened to "sayonara" and gained popularity as a more casual goodbye.
In short, "sayonara" evolved from a more formal phrase "sayō nara" that expressed the meaning of "if it is so, then" and evolved into a common way of saying goodbye.