Electronic compressors as we know them only became widely used in the 60s. That doesn’t mean people weren’t using compression before then, though, they were just doing it ‘by hand’…
In the broadest possible sense, compression is about managing dynamic range. Dynamic range is the difference between the loudest and softest sounds in a song or performance. Voice, bass guitar and percussion all have a naturally wide dynamic range, whereas solo flute or sustained string chords tend to be much less ‘peaky’, that is, more consistent and with less dynamic range.