I understand that's what it does, but I don't understand how/why it does it.

The simplest explanation for the unbypassed case is the gain is the ratio of the drain resistor to the source resistor,

Av ~ - Rd / Rs

However the JFET acts like there is a resistor in series with the source with value rs = 1 / gm. Where gm is called the transconductance. With this included you get a more accurate expression,

Av = - Rd / (Rs + rs)

When you bypass the source resistor this becomes

Av = - Rd / rs

Since the denominator is smaller it means the gain is higher.

When you add the bypass cap is creates a transition between the two gains. The frequency where the transition occurs depends in the value of the cap and the values of Rs and rs.

It's possible to explain why the gains are what they are a different way. The input voltage effectively appears across the total source resistance; (rs + Rs) for unbypassed and rs for bypassed. That means a current vin / (rs + Rs) flows in the drain resistor. For a JFET the drain current and the source current are the same value so that means the source current is also vin/(rs + Rs). Now observe that the source current flows through the resistor Rd. The output voltage = Rd * source current. So that means the output voltage is Vout = Rd * (Vin / (Rs + rs) ). The gain is Vout/Vin = Rd /(Rs + rs). So that shows where the results above come from.

For more formal reasoning you need to find some PDF's on the gain of common-emitter amplifier with an without bypassed emitter resistors. Most of this stuff is explained regarding transistors (BJT's) not JFETs but the ideas are exactly the same.

Most formal stuff will have more maths. In the above I've started with the least mathematical way to "explain" it.