Reducing the size of the image takes pixels away, effectively reducing the resolution of the image. Of course, the file also gets smaller. If you save as a high-fidelity JPEG (say 95%), this may be all the file size reduction you need.
Reducing the size of the file with a lossless method (eg PNG) will achieve a reduction in file size with no loss of quality — hence the name. The reduction depends on the image: a picture with many identical pixels, eg a screenshot of this page, will compress substantially.
Using a lossy method (eg normal JPEG compression) will result in an even smaller file, but you will pay for this reduction with a loss of quality. Most methods of saving JPEGs allow you to choose a fidelity, often 80% by default, which controls the quality of the resulting image; this is the line that does it in the code you posted: