This is an ISO standard by the Joint Photographic Experts Group. JPEGs work with color resolutions of up to millions of colors (also called 24 bit color). When you save an image as a JPEG, it gets compressed, making the file smaller. However, JPEG compression is lossy, so each time you save a JPEG, you lose some data and reduce image quality.
When saving a JPEG, you can choose a compression level from low to high. Low compression gives you better quality but a larger file size. High compression gives you a smaller file - but less quality.