It all comes down to the properties of the pairing operation (commonly denoted as $e$, called pairing
in the code).
$e$ is a function that takes two elliptic curve points as inputs, and generates a value for which multiplication and exponentiation makes sense (in practice, it is an element within an 'extension field', however you don't need to worry what that means)
One property that $e$ has is this identity:
$$e(aG, bH) = e(G,H)^{ab}$$
This identity is true for any integers $a, b$, and any two points $G, H$.
The BLS signature verification logic relies on this: if the public key is $P_2 = xG_2$ (and $G_2$ is also known by the verifier), and the message is mapped to a point $H(m)_1$, and the signature is $S_1 = xH(m)_1$, then the standard BLS verify (assuming a valid signature) computes the two pairings:
$$e(P_2, H(m)_1) = e(xG_2, H(m)_1) = e(G_2, H(m)_1)^x$$
$$e(G_2, S_1) = e(G_2, xH(m)_1) = e(G_2, H(m)_1)^x$$
If the signature is invalid, the second equation evaluates to something else.
If $S_1$ is in fact $xH(m)_1$ (that is, if the signature is valid, these two values are the same.
Now, the Ethereum BLS verification logic is equivalent, but works slightly differently: it instead computes (again, if the signature is valid):
$$e(G_2, -S_1) = e(G_2, -xH(m)_1) = e(G_2, H(m)_1)^{-x}$$
Remember, negating a point is the same as multiplying it by -1.
And again, if the signature is invalid, it evaluates to something else.
And so, if the signature is valid, the verifier has just computed the two values $e(G_2, H(m)_1)^x$ and $e(G_2, H(m)_1)^{-x}$; these are multiplicative inverses of each other, and so multiplying them together evaluates to one.