Chords and scales are built from intervals, or two pitches played in sequence or simultaneously. Depending how you count, there are only half a dozen to a few dozen intervals that make up the 12tone system.
The Octave
(See Octave.)
The octave has a special place in almost every musical culture (and perhaps in some nonhuman animals) and is based on how the inner ear processes sound and how the brain perceives it. (See footnote in Tymoczko 2011, p. 30.) The physical vibrations of a note played on an instrument also produce many strong octave overtones so acoustics play a role.
Tap to hear an octave played sequentially then simultaneously.
We can take any string of a violin, say the A string, and demonstrate what an octave is. Simply pluck or bow the open string, the note A4 .* A4 is tuned to 440 Hz, which is essentially arbitrary, but important so that musicians can play together. Historically this reference pitch for A4 has differed between 415 Hz to 460 Hz.
Now simply measure 1/2 the length of the string and press down on the string to stop it.* Measure from the nut near the pegbox to the bridge, making the distance from the inside edge of the finger to the bridge half of the original length of the open string. Now pluck or bow this note (between bridge and finger), A5 . An octave is the interval formed by playing these two notes in succession (or together, which would require multiple strings).
We can repeat this process, making the length of the string half as long again, to create an octave between A5 (middle of string) and A6 , where 3/4 of the string is stopped, leaving 1/4 of the string to vibrate and make a rather highpitched note.
A3 to A4 to A5 sounds evenly spaced to the ear, but each note is double the pitch of the previous one (220 Hz, 440 Hz, 880 Hz) since the string length, and hence the wavelength, is halved each time.
A similar process works for other types of instruments, but a simple, single string is the easiest to understand.
Pitch & Intervals
We can continue the example of a single string divided by a single finger to generate all of the intervals. (Distances are measured as a fraction of the distance from the nut to the bridge.)
1st Note  2nd Note  ÷ of A string  ~ # Semitones  Name of Interval  

Open A string  A4  A5  1/2  12  Perfect Octave  
—  —  —  —  —  —  
Open A string  A4  D5  1/3  5  Perfect Fourth  
Open A string  A4  C  51/4  4  Just Major Third  
Open A string  A4  C5  1/5  3  Just Minor Third  
—  —  —  1/6  (2.66...)  —  
—  —  —  1/7  (2.31...)  —  
Open A string  A4  B4  1/8  2  Just Whole Tone  
—  —  —  1/9  (1.82...)  —  
—  —  —  1/10  (1.65...)  —  
—  —  —  1/11  1.5  Just Three Quarter Tone  
—  —  —  1/12  (1.39...)  —  
—  —  —  1/13  (1.28...)  —  
—  —  —  1/14  (1.19...)  —  
—  —  —  1/15  (1.11...)  —  
Open A string  A4  A  41/16 or 1/17  1  Just Semitone  
—  —  —  —  —  —  
Open A string  A4  D  52/5 or 7/17  6  Just Tritone 
Off By a Bit
Experienced readers will notice that we have oversimplified things slightly. This can best be demonstrated by pulling out a guitar and trying the same thing on the A string.
We immediately notice that the metal frets of the guitar have forced us to divide the string at certain discrete locations, to play certain pitches. These distances are nearly the same as those on the violin, but off by a little. The difference between the fractional finger locations on the violin and the irrational fret locations on a properly tuned and intoned guitar illustrates the difference between justintoned intervals and equaltempered intervals.* (See TwelveTone Equal Temperament and Tuning Systems.) The ratios are equal to 2^{n/12} – 1, for n semitones. This distinction is important but subtle and does not effect the musical set theory analysis to follow, since the analysis can account for continuous pitch spaces, which includes all tuning systems (even though we will only apply it to 12TET).
Interval Classes
We can reduce the number of intervals to keep track of by by collecting them into six groups, giving us a fairly simple, but still robust foundation for analyzing the chords and scales we come across, going forward. (See Clocks & Pitch Classes.)
In musical set theory, the octave and unison are not treated as intervals (see octave equivalence) and all possible intervals are grouped by inversion into six interval classes, denoted by colors in the intervals table.

Minor second / Major seventh
1 semitone + 11 semitones = 12 semitones (1 octave)

Major second / Minor seventh
2 semitones + 10 semitones = 12 semitones (1 octave)

Minor third / Major sixth
3 semitones + 9 semitones = 12 semitones (1 octave)

Major third / Minor sixth
4 semitones + 8 semitones = 12 semitones (1 octave)

Perfect fourth / Perfect fifth
5 semitones + 7 semitones = 12 semitones (1 octave)

Tritone (its own inversion)
6 semitones + 6 semitones = 12 semitones (1 octave)
Equaltempered intervals that share an interval class (six classes above) have mathematically related tuning ratios (a × b = 2, e.g. P4 × P5 = 2, or 4/3 × 3/2 = 2), with the same amount of purity or impurity (tuning error compared to their justintoned interval peers).
For more on interval classes, see Intervals as Prime Forms.