When did Apple rename Mac OS X to macOS?
Apple Inc. renamed Mac OS X to macOS with the release of macOS Sierra (10.12), on September 20, 2016.
Why did Apple rename OS X to macOS?
Apple tend to not discuss the "why" of their strategies too much, but it seems to be to make the name of their desktop operating system (macOS) closer to how they name their mobile operating system (iOS).
Given Apple's massive focus on mobile devices (with the iPhone and iPad), and also Apple's plan to move away from Intel processors to a CPU they design themselves (just as the did with iPhone/iPad), it's not too hard to imagine that one day they plan to unify their entire device line so that the same OS runs on mobile devices and desktop devices (because it's the same kind of hardware!)
 pure speculation on our behalf, but really not that far out of an idea...