Why is it that when I read an old book they spell goodbye as “good-by” but now it’s pretty much an unwritten rule to spell it “goodbye” or “good-bye”?

Welcome to the SDMB.

The phrase “Good-Bye” originaly comes from “God-be-with-you”. The pronounciation of such things mutates along the centuries, and the spelling along with them.

I don’t have the most recent OED, which might show some more citations, but the earlier edition did not even have a reference to “good-by.” They show “Good bwy” (God be wi’ y(e)) from the early 1700s, then “good-bye” from 1811.