Data compression refers to the problem of finding a code that makes the average length of an encoded message as short as possible. This is sometimes called "source coding" because the most compressed code depends on the properties of the Information source producing the message.
https://en.wikipedia.org/wiki/Data_compression
Lossless compression
Lossy compression
Why does data compression work?
Because real-world data very often has Order (i.e. structure), and is thus compressible. One measure for such order is Randomness deficit, and one explanation for it is that Nature is algorithmic, i.e. the data we observe often is a result of some (relatively simple) algorithm.
Compression - Computerphile Entropy in Compression - Computerphile
Related