A scale is a sequence of notes and so a scale sounds good if these notes have some relationship between each other.
A just tempered scale, also known as "just tempered tuning" or "just tuning", is a scale in which the frequencies of notes are related to each other by a multiple of a rational number.
A rational number can be represented by a fraction and so knowing the frequency of one note in a just tempered scale we can get the frequencies of other notes by multiplying and/or dividing by integers. In other words, just tempered scales use harmonics to construct one note from another.
Suppose that we set the note A at 440 Hz. Then A an octave higher should be 880 Hz, which is an exact even order harmonic of A at 440 Hz. Then there are two ways to compute the frequencies of notes between A at 400 Hz and A an octave higher at 880 Hz.
One way is to use an equal tempered scale. An equal tempered chromatic scale would split the frequency interval between A = 440 Hz and A = 880 Hz into twelve equal intervals for each of the twelve semitones. Thus, A# = 440 * 21/12 Hz, B = 440 * 22/12 Hz, C = 440 * 23/12 Hz, and so on. The note E, for example, would be E = 440 * 27/12 = 659.26 Hz. In such a scale the ratio between two adjacent notes is always the same: 21/12. Hence, the scale is called "equal tempered".
A just tempered scale would be built differently. Rather than splitting the A to A interval evenly, one would set the notes at frequencies that are close harmonics of the base frequency A = 440 Hz. For example, the note E could be built using an odd order harmonic of A. A good start is E = 440 * 3 = 1,320 Hz. This E is one octave too high though, so E = 440 * 3 / 2 = 660 Hz is better. This E differs from the E = 659.26 Hz in the equal tempered scale.
Thus, even splitting of an octave in 12 semitones gives us E = 659.26, whereas using harmonics gives us E = 660 Hz. Each has advantages and disadvantages. The E in the just tempered scale would sound better, as A and E (and other notes) are harmonics of each other. However, since a just tempered scale does not split the frequency interval evenly, music performed in the just tempered scale would sound different when transposed (unless instruments are re-tuned starting with a different base note).
Each frequency has many harmonics and hence, there are many ways to build a just tempered scale starting from some note. The closer the harmonics are, the better notes sound together. For example, E above was built using the computation E = A * 3 / 2. Technically, E = A * 3 is the closest odd order harmonic of A (the closest even order harmonic of A is A = 2 * A; just an A an octave higher). This E is the just fifth of A (in other words, E, the fifth of A in common seven-note (heptatonic) scales, depending on tuning, could be "just" as in this case, or not just, as in equal tempered scales). E is called the dominant in a heptatonic scale as it is the most pronounced harmonic of the base note A, except for the tonic (the A itself). A and E should sound well together then. Compared to E, an A# could be A# = A * 25 / 24. A# in this example is still a harmonic of A, but not as close of a harmonic as E.