In short words file compression is finding the redundant parts (bytes, words) from inside a file and then building a dictionary (an index) based on their position inside the file. Then, instead of the actual words use the index number. This way you are able to compress a big text file to a 1/10th or even 1/1000th of its original dimension. Then, using a program like WinZip you are able to recreate exactly the file you you compressed.
When you are able to create exactly the original file the compression is called lossless. This is usually done with text information. But when you want to compress images, then that compression is lossy, meaning that it looses some of the information while compressing the file.
Learn more about text compression:
Learn even more about image compression: