HTML written for humans is full of things a browser does not need. Indentation showing nesting. Blank lines separating sections. Comments explaining what a block does. None of it affects rendering, and all of it is downloaded by every visitor.
Minifying removes it. On a typical page the saving is 15% to 25% before compression - modest on its own, but it applies to every request, and it costs nothing.
What gets removed
Comments disappear entirely. Worth pausing on: developer comments often contain more than intended. Notes about which server a feature is on, references to internal tickets, commented-out code showing an earlier approach, the name of a plugin and its version. None of that should be public. Stripping comments is as much a hygiene measure as a size one.
Conditional comments for old versions of Internet Explorer are preserved, since removing those would change behaviour on the browsers that still read them.
Whitespace is collapsed. Runs of spaces become one, and the gaps between tags are closed up. This is where most of the saving comes from in deeply nested markup.
Line breaks can be removed entirely with the third option, producing a single unbroken line. Maximum compression, zero readability.
What is deliberately protected
Four elements are left exactly as they were: <pre>, <textarea>, <script> and <style>.
The reason is that whitespace inside them is significant. Collapse the spaces in a <pre> block and your carefully formatted code sample turns into one line. Collapse them in a <textarea> and the default value the user sees changes. Remove line breaks inside a <script> and any JavaScript using single-line comments breaks, because everything after // on that line is now commented out - including the rest of your script.
This is the most common way a naive minifier breaks a page, and it is why those four elements are stashed aside before minification and restored afterwards.
The whitespace that does matter
One caveat worth understanding. In normal HTML flow, whitespace between inline elements is rendered as a space. If you write <span>one</span> <span>two</span> with a line break between them, the browser shows a gap. Collapse it and the words run together.
This affects inline elements - span, a, em, strong, img - not block-level ones. Modern layouts built with flexbox or grid are largely immune because those layout modes ignore the whitespace anyway. Older markup that relies on inline-block spacing is not. Check the visual result on a page or two before minifying a whole site.
Where it fits
For a site with a build step, minification belongs there. This tool is for the cases that do not have one: a landing page you are pasting into a CMS, an email template, a static file you are uploading by hand, or simply checking how much weight a page could shed before deciding whether it is worth automating.