The reason behind those worse quality images you get to see after you upload a picture to social media sites like facebook, instagram and twitter or share via whatsapp, viber and messenger is quite amusing.
The reason behind the compression is to save the space in their servers.
First reason is to save the bandwidth. Reason behind those messed-up quality is the compression that takes place behind the scene. When you upload a high quality image to facebook, instagram or twitter, it gets compressed in such a way that the image quality tries to retain the maximum possible quality while reducing the file size to a bearable minimum. For example, if you upload a picture of 4 megabyte, it gets compressed to couple hundred kilobytes. The only way to compress a file is by omitting certain detail while still maintaining the visibility of an image. You certainly loose the quality but the benefit of the compression is the image gets loaded faster complying with your internet bandwidth. Slower the file, faster is the loading time. Simple as that. Another reason behind the compression is also intriguing.
For example, if you upload a picture of 4 megabyte, it gets compressed to couple hundred kilobytes.
Websites like facebook, youtube, twitter and instagram have their own storage servers, also sometimes referred as data centers, have millions of physical hard drive for storing your pictures and data. This applies to every popular website out there in the world wide web. Those hard drives are the same ones that are found in your home computer. Those giant storage servers have millions of such hard drives so that they could store data of their millions of customers. They store every data you upload like pictures, videos and documents. Since Facebook and Youtube offer unlimited free uploads, the only way to save those spaces is to compress the pictures and videos to a bearable limit. Hence the reason behind the compression is to save the space in their server. There are certainly some other ways or “hacks” to upload a full quality images but we will get to that later.

Therefore in simple terms, the reasons behind the picture quality loss is number one – faster loading even during slower internet connection, and number two – save space in storage servers.