JPEG stores images as blocks of frequencies. The quality setting decides how precisely those frequencies are kept. Above quality 85 the extra bytes go into detail no display can reproduce; below about 60 the blocks start to show. Between those numbers is where a compressor should land, and this one searches for the highest quality that fits your size cap.
It also removes EXIF metadata (camera model, GPS location, thumbnails), which can be 20 to 100 KB by itself and is a privacy risk when sharing.