There are an infinite number of ways to choose a set of pitches from which to make music, and for the most part, cultures worldwide have chosen sets of pitches related to each other by small number ratios (the gamelan music of Indonesia is one of the notable exceptions). That is, given one pitch in a scale or chord, we can get any other by multiplying the first by some simple fraction such as 3/2 or 5/4. People choose sets of related pitches to play and sing with unconciously, and the most basic ones generally agree from culture to culture (3/2, 5/4, 6/5, 4/3, etc). Why? Because simply related pitches sound nice when played together.
Here's how it works. When pitches whose ratios are simple are played together (the frequency of one is, say, 5/4 times the frequency of the other, as 400 cycles per second played with 500 cycles per second) we hear what is referred to as a consonance (roughly "together sounding"). The waveform (a picture of how the air pressure changes with time) of a consonance repeats its shape regularly, and something about the human auditory and nervous system causes us to find this regularity of sound pleasing. There are a lot of theories as to why this happens, and some that claim this does not happen, but these threads can be persued through the acoustics link on the previous page.
Anyhow, although pure intervals whose pitches are related by small number ratios sound sweet and pure, it is difficult to make musical instruments that can play these pitches and also play in different keys. If you try to tune a piano or guitar to pure intervals related to say, C or E, you certainly can do it, but if you then try to play in any other key than these the music will be out of tune. This is because "natural" sounding chord progressions rely on common pitches between chords, such as CEG (C major triad) to ACE (A minor triad). The common pitches C and E are playing different roles in these two chords, the root and major third of C major and the minor third and perfect fifth of A minor. Sometimes these dual roles are compatible and sometimes they are not.
When we build chords in the simplest way, from a fundamental pitch, say C, and simple fraction multiples of this pitch, we can see where things go wrong. First, a couple of conventions.
Here's an example:
3/2 is often called the fifth, because it is the fifth pitch in a diatonic scale,
like C D E F G A B C. 5/4 is the ratio often called the major third, which would be E in the key of C,
for instance. What ratio is a major third up from the fifth?
3/2 * 5/4 = (3*5)/(2*4)=15/8
Example 2: What is the ratio of a pitch a minor third (6/5) down from a perfect fourth (4/3)? We must
divide 4/3 by 6/5.
4/3 / 6/5 = 4/3 * 5/6 = (4*5) / (3*6) = 20/18 = 10/9
where we have divided out the common factor 2 from both 4 in the numerator and 6 in the denominator.
Example 3: What is a perfect fifth up from a perfect fifth?
3/2 * 3/2 = 9/4.
This is larger than 2 (since 9/4 = 2.25) so we divide by 2 to bring the pitch down an octave.
(9/4) /2 = 9/8.
O.K., we're ready to go.
We can build a major scale C D E F G A B C by using the pitches from 3 major chords, C major (CEG) F
major (FAC) and G major (GBD). The simple ratios that correspond to these chords are
1/1, 5/4, 3/2 (CEG),
4/3, 5/3, 2/1 (FAC) and
3/2, 15/8, 9/8 (GBD).
Put these ratios in a scale in ascending order and we have
the classic one octave diatonic scale
1/1, 9/8, 5/4, 4/3, 3/2, 5/3, 15/8, 2/1 (C,D,E,F,G,A,B,C).
These three major chords, built on the first, fourth and fifth degree of the scale have a nice property-the major third and perfect fifth of each of them are related by the same fractions. To get the pitches in the C major chord, multiply its root (1/1) by 5/4 and 3/2 successively--1/1*5/4=5/4, 1/1*3/2=3/2. The same multiplication works to get F major--4/3*5/4=5/3 (A) and 4/3*3/2=2/1 (C). The G major chord may be built as 3/2*5/4=15/8 (B), and 3/2*3/2=9/4 which is larger than 2/1, so we divide by 2 to get 9/8 (D).
Buoyed with confidence, we try to build triads on every degree of the scale (it worked for C, F and G, so why not?). The ratio for a minor third is 6/5, and we find there is a minor triad on A (ACE) whose ratios are 5/3, 1/1, 5/4. Now 5/3*6/5=2/1 and 5/3*3/2=5/4 (after we divide by 2). So far so good. There's one on E too, EGB with ratios 5/4, 3/2, 15/8, and again, multiplying the root by the same fractions we used to get the A minor triad works--the root is E=5/4, and 5/4*6/5=3/2, 5/4*3/2=15/8. Good. These ratios are all in the major scale we built from the C, F and G major chords, and the pitches in A minor and E minor were obtained by multiplying by the same fraction. There should be a triad built on D (9/8) so let's find it. But 9/8*6/5=27/20, and 9/8*3/2=27/16. Neither of these is in the original ratio scale. Maybe the D triad should be a major triad. But 9/8*5/4=45/32, and 9/8*3/2 is still 27/16. This is no good. If we want a triad on D, we have to add more pitches to our scale.
Of course we can add all the pitches we want and build instruments that can play these, but the more pitches there are on an instrument the harder it is to play. That, along with the beauty of common tone chord progressions, is why we like to have each pitch do double and triple duty. Furthermore, we sometimes like to change key, and that puts even more pressure on us to have pitches that can wear more than one hat (G is the root of G major, the fifth of C major, and the minor third of E minor). When we try to use the available pitches from our ratio scale to build a D triad, we get DFA = 9/8, 4/3, 5/3, and this chord sounds horrible to most people (some people like their harmony jangly, and to them I say go for it). But to the majority of the musical western Europeans of the 17th century, this situation was unsatisfactory. When we add enough extra pitches so that we can play major and minor chords on all scale tones, either we have an unwieldy bunch of pitches, or a nice compact set of 12 (like our chromatic scale) that for the most part are out of tune.
To be sure, several instruments with sufficient tonal resources were built (mostly keyboard like things, since the organ was king in the 17th century) but they were more expensive and difficult to learn than simpler 12 tone per octave keyboards.
Composers, players and instrument builders have known about this for centuries, and have tried many things to get around this "problem" (many cultures do not consider this a problem. They just play in one key and develop musical complexity in other was, such as rhythmic or melodic complexity). The musically minded found that if they put a few of their pitches a little out of tune, not enough to be very noticable, then some of the "nearby" keys weren't so badly out of tune anymore. This method was called "mean tone tuning", the term "mean" being used in the sense of "average", since they were averaging out the out of tuneness. In fact, they kept putting more and more of the pitches out of tune (choosing carefully, of course), enabling them to play in more and more distant keys (the key of G is "close" to the key of C on a piano because there is only one note different between them, F and F#. On the other hand, the key of E is more distant from the key of C because they differ at (F,F#), (G,G#), (C,C#), (D,D#).
In the late 1700s in Europe, a tuning system that put all the pitches out of tune with each other except the octave began to gain wide acceptance. This system was 12 tone equal temperament, and it put all the pitches out of tune by spacing them exactly equally distant from their neighbors. Mathematically, this meant that any two adjacent chromatic tones differed in frequency by a factor of 2^(1/12) (the twelveth root of 2), which is about 1.06. Using this number as the basic multiplier to get from one note to the next in a scale results in a set of pitches that does not vary from the pure pitches by more than about 17% at the worst. This deviation gradually became accepted in the west, as it gave music the power to modulate to any of the 12 "standard" keys and not sound completely aweful.
With the modern digital systhesizers we can now play in pure tunings (and and infinite number of other interesting tuning systems) in any key we like without being out of tune! Why haven't we been hearing music in Just Intonation then? Because the 12tet tuning system is so ingrained in almost all instruments, recordings and school curricula that all other systems have been all but forgotten in the USA and ECC. John Starrett's Microtonal Music Page