Music is made of relationships rather than absolute pitches. Sing a tune starting anywhere and it stays recognisably the same tune, because what the listener tracks is the interval: the distance from each note to the next.
Naming the distances
Intervals are named by counting letter names inclusively, starting from the lower note. C up to E spans C, D, E, so it is a third. C up to G spans five letters, so it is a fifth. The octave is an eighth.
Because the letters are unevenly spaced, each name comes in sizes. A third can be major (four semitones, C to E) or minor (three semitones, C to E flat). The one-semitone difference is small in measurement and enormous in effect: it is most of what separates music that sounds bright from music that sounds sad.
Fourths, fifths, and octaves come as perfect instead, having only one common form, and they are the most stable-sounding intervals of all.
Why some pairs agree
The character of an interval is not a cultural accident. It comes from how the two notes' harmonics line up.
Simple frequency ratios produce many shared harmonics and little clashing, which the ear hears as consonance. The octave is , the perfect fifth is close to , the perfect fourth close to . These are the sweetest, most restful combinations, and they are the intervals that appear first in almost every musical tradition.
Complicated ratios produce harmonics that sit close together without matching, and closely spaced frequencies beat against each other, producing a roughness the ear reads as dissonance. A minor second, two adjacent semitones sounded together, is the classic example, and film composers have used its unease for a century.
Tension and release
Dissonance is not a defect to be avoided. It is the engine of musical motion. A consonant chord is stable and can sit still; a dissonant one feels like it is leaning somewhere, and resolving it to a consonance produces the sensation of arrival that most music is organised around.
The tritone, exactly half an octave, is the most restless interval of all and was nicknamed diabolus in musica. Left alone it is intolerable, but it is precisely its urge to resolve that gives Western harmony its forward pull.
Building blocks
Intervals are the atoms here. Stack them in a line and you get a scale; stack them at the same time and you get a chord. Both are next.