Derivation
The Maxwell relations follow directly from the fact that partial derivatives commute: $\partial_x \partial_y = \partial_y \partial_x$.
If we have some function $U(S,V)$ (called the internal energy) that depends on the entropy $S$ and the volume $V$, the total change of it is given by
$$ dU = \frac{\partial U}{\partial S} \big |_V dS + \frac{\partial U}{\partial V} \big |_S dV, $$
where $\big |_V$ means that we keep $V$ fixed.
Then, we introduce two definitions:
$$ \frac{\partial U}{\partial S} \big |_V \equiv T , \quad -\frac{\partial U}{\partial V} \big |_S \equiv P.$$
The minus sign here is just a convention and can be understood as follows: The internal energy usually gets smaller when we increase the volume. Thus, if we want to work with positive pressure $P$ in most situations, we need to include the minus sign here.
Using these definitions equation reads
$$ dU = T dS - P dV, $$
which is the fundamental thermodynamic relation.
Next, we use that partial derivative commute:
$$ \frac{\partial^2 U}{\partial V\partial S} = \frac{\partial^2 U}{\partial S\partial V} $$
and put in our two definitions from above:
$$ \frac{\partial T}{\partial S} \big |_V = -\frac{\partial P}{\partial V}\big |_S $$
This is one of the Maxwell relations.
The other Maxwell relations follow completely analogous, but with different functions instead of the internal energy $U$.
For example, if we start with the Helmholtz free energy $A(T,V)$:
$$ A = U -TS $$
and follow exactly the same steps ($dA= dU-d(TS) = (Tds-PdV)-(SdT+TdS)=-SdT-PdV$), we can derive
$$ \frac{\partial S}{\partial V} \big |_T = \frac{\partial P}{\partial T} \big |_V $$
The other Maxwell relations follow by starting with the enthalpy $H(S,P)$ or the Gibbs free energy $G(T,P)$.
(These notions appear, since:
For a great explanation, why the Maxwell relations are "just a sneaky way of saying that the mixed partial derivatives of the function U commute". see https://johncarlosbaez.wordpress.com/2012/01/19/classical-mechanics-versus-thermodynamics-part-1/
(The fact that partial derivatives commute is known as Schwarz' theorem (see https://en.wikipedia.org/wiki/Maxwell_relations . Schwarz' theorem is simply a way of stating "the fact that a function S doesn’t change when we go around a parallelogram" https://johncarlosbaez.wordpress.com/2012/01/23/classical-mechanics-versus-thermodynamics-part-2/)
The Maxwell relations encode useful relationships between notions of thermodynamics.