Attested in the 1570s as "godbwye," a contraction of "God be with ye." The "God" was later reshaped to "good" by analogy with good day and good night, but the farewell began as an explicit blessing.
Assessment: Fully documented. One of the clearest cases of a religious phrase hidden inside everyday speech.
Stories
Protection for a journey
Folk elaboration says the blessing was spoken over travelers facing dangerous roads, and answering it carelessly invited misfortune. No period source records such a rule.
Assessment: A later romantic gloss on the documented origin.
Interesting claims
A blessing you cannot refuse
Decoder circles note that every farewell smuggles God into the contract: to say goodbye is to pronounce a blessing on someone whether they want it or not, proof, they say, that English is liturgy wearing civilian clothes.
Assessment: The contraction is real, the theology is decoration. God be with ye was already a formula before it was compressed. A word's history is not a binding spell on its user.
Sources and further reading
OED, goodbye, contraction of 'God be with ye,' earliest form godbwye, 1573
Worth asking
How many other prayers are hiding inside the things you say without thinking?