All books on music theory appear to me to be going out of their way to make it appear more complicated than it is.
My guess is that music started with something like a tea chest base. The someone figured if you put a fret half way down the broom stick, neck or whatever, you get double the frequency and that sounds good to the human ear. Next they found another spot that sounded good at 1.5 times the openly vibrating string. That has a ring to it and beats nicely.
Also. 1.3333 ( one and a 1/3) times the frequency sounds good. So now you've got 3 frets that sound good, lock them in. Why stop at 3? But there is only one way to now smoothly fill in the gaps. That's with 12 frets. The frets are spaced according to the 12th root of 2. The 5th and the 7th fret are 1.4949 and 1.3327 times the frequency. Close enough to 1.5 and 1.333. Sounds good enough for guitar players.
( Or maybe I should have said that if you try various numbers of frets along the open string to the half way point 6,7 frets...15 frets 16 frets etc you'll only get a fret land on or very close to the two intermediate sweet spots by dividing it down by 12. 12 is not a random number it's a universal number like pi)
So really there should be 12 notes in the scale, 3 sweet ones and 9 random ones. But I think that's just too many for us to comprehend in the one song so it was made confusing with 8. You'll note all the 8 note scales, major, minor, aeolian, etc keep the 4th and 5th, the sweet ones, and fiddle with the rest.
Then of course came piano players, they weren't limited to playing with evenly spaced frets, so they made the 5th exactly 1.5 times the frequency, and the 4th exactly 1.33333. Perfect, but only if you played in the key of C. If you played in Bb it sounded quite different. Didn't Beethoven like Bb? With a stringed instrument you can put a capo on and everything just scales up so basically sounds the same. This small variation of the same 8 note western scale has two names, natural and even tempered. Can't remember which is which.
( just realised i've referred to the note at the 5th fret as the 4th. That's just music theorists trying to confuse us again, I think it's got more names than that even)
pages.mtu.edu/~suits/scales.html