The well tempered or chromatic musical scale is the one we are familiar with in Western culture. The octave is divided into 12 equal semitones, thus:
                                    The 12 semitones
    C#/ D#/     F#/ G#/ A#/            
    Db  Eb      Gb  Ab  Bb             C-C#   F#-G
 |  |$| |$|  |  |$| |$| |$|  |  |$     C#-D   G-Ab
 |  |$| |$|  |  |$| |$| |$|  |  |$     D-Eb   Ab-A
 |  |$| |$|  |  |$| |$| |$|  |  |$     Eb-E   A-Bb
 |  +-+ +-+  |  +-+ +-+ +-+  |  +-     E-F    Bb-B
 |   |   |   |   |   |   |   |   |     F-F#   B-C
 |   |   |   |   |   |   |   |   |
 | C | D | E | F | G | A | B | C |
 |   |   |   |   |   |   |   |   |
 +---+---+---+---+---+---+---+---+

Under the well tempered scale, a given tune can be played in any key without changing the relative pitches in the melody (shifting the key of a tune is called transposing it). This was something of a revelation when it was first introduced, as previous tuning scales could not do this.

J S Bach was the first composer to make widespread use of the well tempered scale. He was a major advocate of its superiority over other tuning systems of the day. His two books of 24 preludes and fugues are entitled "The well tempered klavier" (Das wohltemperierte Klavier), and are dedicated to this system of tuning. There are 24 possible keys, major and minor of each of the notes in the scale. Each book has a prelude and a fugue in each key.

The maths behind the music

What humans hear as pitch is proportional to the logarithm of the frequency. When we hear the pitch being raised by an octave, this is the doubling of the frequency.

What sounds pleasant are harmonics, i.e. exact multiples of the frequency. For the intervals in a melody, we are in fact listening for exact integer ratios.

The well tempered system approximates these ratios, by dividing the pitch change of an octave into twelve equal parts (semitones). Since pitch is logarithmic, we need to raise 2 to the power 1/12.

Semitone = 21/12 = 1.0594630943593

By raising this number to different powers, we get the frequency ratios for each interval, some of which are quite close to harmonic fractions.

Semitone         = 1.059463
Tone             = 1.122462
Minor Third      = 1.189207 (compare 6/5 = 1.2)
Major Third      = 1.259921 (compare 5/4 = 1.25)
Fourth           = 1.334840 (compare 4/3 = 1.3333)
Diminished Fifth = 1.414214
Fifth            = 1.498307 (compare 3/2 = 1.5)
Minor Sixth      = 1.587401
Major Sixth      = 1.681793
Minor Seventh    = 1.781797
Major Seventh    = 1.887749
Source:     http://www.ixpres.com/interval/dict/well.htm

See also:     http://www.kunstderfuge.com/bachWTK2.htm