The formula, and why it works
For A = [[a, b], [c, d]], the inverse is A⁻¹ = 1/(ad − bc) × [[d, −b], [−c, a]]. The matrix on the right is the adjugate: swap the diagonal, flip the signs of the off-diagonal.
You can check it by multiplying. A times the adjugate gives (ad − bc) times the identity, so dividing by ad − bc gives the identity itself. That is exactly why the determinant has to be non-zero: it is the number you divide by.
When there is no inverse
If ad − bc = 0 the matrix is singular. Geometrically, the two rows (or columns) point along the same line, so the matrix squashes the plane onto a line and cannot be undone. [[2, 4], [1, 2]] is an example: the first row is twice the second, and 2 × 2 − 4 × 1 = 0.
The same idea scales up: for 3×3 matrices the test is whether the determinant, found with the rule of Sarrus, is zero.
What the determinant measures
|ad − bc| is the factor by which the matrix scales areas. The unit square becomes a parallelogram of area |ad − bc|; a negative determinant means the picture is also flipped. That link is why determinants show up again in the area of a parallelogram.