A compression algorithm is used to take some data and reduce the size of the data through the use of formulas. The data can be in any form, a file on a hard disc or even data coming from the internet. Data compression is used for many reasons. To allow more information to be stored on a hard drive, to allow information to be transmitted from point A to point B quicker, and even to make it harder to decipher when transmitting sensitive information. It helps increase the load time on websites and images as well.
When you compress images for example in a website, the image may not look to be the same quality, but it is definitely still clear to the naked eye and still sends the message of the website. This however, reduces the time it takes to load the website and thus makes it more user friendly. Obviously if you compress an image too much, the image will not look as good anymore but there is a happy medium.