What DPI and quality actually change
One controls how many pixels a page has, the other how carefully those pixels are stored. Mixing the two up is why exports come out either blurry or enormous.
What does DPI actually mean here?
How many pixels are produced for every inch of the page. A US Letter page at 150 DPI comes out 1275 by 1650 pixels; the same page at 300 DPI is 2550 by 3300, which is four times as many pixels and roughly four times the file size.
DPI only means anything where a physical page exists, because it describes the conversion between paper inches and pixels. It applies when you render a PDF to images or scan paper into one. Text stored as text has no DPI at all: it is drawn fresh at whatever size you view it.
Which DPI should I choose?
150 for reading on a screen, 300 for printing or for recognition, and 72 only for a thumbnail. Those three cover nearly every job, and going above 300 rarely produces anything a person can see while it always produces a file they have to wait for.
Recognition is the one case with a hard floor. Character recognition needs roughly 300 DPI on ordinary body text to be dependable, and feeding it a 150 DPI scan is the most common reason results come back full of near misses.
What does the quality setting do?
It decides how much detail the JPEG or WebP encoder is allowed to throw away. At 90 the encoder keeps almost everything and the file stays large; at 50 it discards aggressively and the flat areas around text begin to show blocks.
Quality does not change the pixel count, which is why lowering it runs out of road: a 300 DPI scan at quality 40 is still a 300 DPI scan, and it will be both ugly and larger than the same page resampled to 150 DPI at quality 80.
When does none of this apply?
When the format has no lossy stage. PNG stores every pixel exactly, so it has no quality setting at all, and its size is decided by resolution and by how much flat color the page holds. That makes it right for screenshots and diagrams and wrong for photographs.
It also stops applying to any page that is real text. Converting a text page to an image at any resolution throws the text away and leaves a picture of it, which is why exporting to images is a delivery format rather than a working one.
Where to go from here
PDF to JPG and PDF to PNG both put the resolution in front of you before the export, and compressing a PDF turns the same two dials on the images already inside the file.
Making a PDF smaller shows what the two settings are worth in bytes, and what OCR can and cannot read covers the resolution floor recognition needs.