Because Apple's hardware lineup is made up of just a handful of computers (laptops, Minis and desktops), it can afford to spend its time tweaking macOS on all the aforementioned pieces of hardware endlessly and thus making them 'nicer' to use with excellent optimization. Apple does charge a premium for the experience.
Windows on the otherhand, is Microsoft trying to be the jack of trades with infinite number of hardware combinations on a huge scale. The probability of something going wrong somewhere is always there. So while it may not be perfect, it's good enough for the majority who cannot afford Macs or dislike its closed wall approach.