Just intonation tunes each interval to a simple whole-number frequency ratio, such as 3:2 for a perfect fifth or 5:4 for a major third, so chords sound very smooth. But these ratios don't fit neatly together: stacking twelve pure fifths overshoots seven octaves slightly, so a keyboard tuned purely cannot play in every key without some intervals sounding out of tune.
Equal temperament solves this by splitting the octave into twelve identical semitones, each with a frequency ratio of the twelfth root of two. Every key sounds equally (slightly) imperfect, which lets instruments like pianos modulate freely, and it became the standard in Western music largely for that flexibility.