In A Nutshell
This topic can easily and quickly become complicated so I'll keep it as straightforward as I can. You may need a little extra background about vibrating strings, intervals and pitch ratios which I will include elsewhere. Meanwhile...
...take a starting note (any note) and add the interval of a 5th to obtain another note (for example, start on a C; the interval of a fifth above this is G). Add to this eleven more 5ths and you end up on the note C again, but seven octaves up. If you were to analyse this in terms of the vibrating frequencies of each note you would discover that the upper C is just a touch more than six octaves up. That is a nuisance. Adding 5ths was Pythagoras's preferred method for obtaining all the notes that can lie within an octave. Because the ancient Greeks' music was usually monody (single lines, no harmony) and performed only within the range of about a single octave, this wasn't a worry. However, when polyphony and the harmony of multiple lines of music became important, this tiny niggle became a big niggle. To solve it, various compromises were tried, whereby notes were either raised or lowered in order to suit the harmony requirements. The process of creating a compromise is called "tempering". It wasn't only harmony that needed this tempering of an instrument's tuning; it was also required as a pragmatic way of making a single instrument with fixed notes (for example, the piano) capable of playing in any key. 
Pythagoras's Scale
To create his scale, Pythagoras used the method of adding 5ths but also when necessary dropping the resulting notes by an octave to keep them within the range of the original single octave...
...take a starting note, say C. The 5th above this is G and is within an octave range. Now add another 5th interval and you arrive at D, now outside the octave range. Drop the D by an octave. Add a 5th to this D and you have A (no need to drop as it is within the compass of the starting octave). Add a 5th to obtain E and drop it an octave. Add a 5th to obtain B. No need to drop. We have thus obtained all the notes of the scale (C, G, D, A, E, B reordered are C, D, E, G, A, B) with just one missing, the F. Pythagoras finally included this note in his scale on the basis that its ratio of vibration was a simple one (obtained by dividing his monocord in the ratio 3/4 (an interval of a 4th). We now have our complete scale, C, D, E, F, G, A, B and back to C  or, as we have just seen, almost! Cycle of 5ths

Working Out The Problem
The maths that reveals our excruciating little problem is quite straightforward and well worth a glance:
The interval of a 5th is obtained when a vibrating string is divided by the ratio 3/2. To add another 5th interval to this is to increase the frequency of the vibrating note by another 3/2, that is 3/2 x 3/2. In our cycle of 5ths this is done twelve times so the final note has the frequency of the original note multiplied by 3/2 twelve times, which is 129.746 This should be seven octaves above the starting note. The octave ratio is 2/1, so seven octaves is 2/1 multiplied seven times, which is exactly 128. By adding 5ths we overshoot the top octave by an exasperating small interval of 129.746/128 = 1.014:1. This unfortunate discrepancy, called a "comma", is about a quarter of a semitone and renders that note unusable as an octave harmony. Equal Temperament
The method that became almost universally accepted for tempering, or adjusting the notes of a scale, is called "equal temperament" and it is so ubiquitous that our ears are so attuned to it as not to notice the compromises that it contains.
In this tempering method, within each exact octave the fifths are slightly flattened and the tones and semitones in between are spaced evenly to fill the octave space. Only the octave notes themselves are "in tune" but the compromise is small enough to be almost negligible. Another method of tempering used during the Middle Ages was called "pure", "natural" or "just". In this method the ratios between pairs of notes were made much simpler, the result being much smoother harmony when notes are played together. 