Energy at constant Entropy and Volume
A function such that the equilibrium state of a system is determined by its maximum (or minimum) is called a characteristic function. There is a whole bunch of those. All they are ultimately derived from the Second law after some fiddling around with differentials.

The said law basically postulates that entropy is one such function. But it is only good for closed systems, that is, those with constant $U$ and $V$. Other kinds of systems use other kinds of characteristic functions. To derive them, we typically go along the lines of Legendre transformations. Say, you have $f(x,y,z,\dots)$, which is a characteristic function in the variables $x,y,z,\dots$, and you want to switch from $x$ to $f'_x$ to use it as your independent variable. Then $f-xf'_x$ is a characteristic function in your new variables.

So let's begin with switching from $U$ to another variable. The new characteristic function is
$$S-U\cdot\left({\partial S\over\partial U}\right)_V=S-{U\over\left({\partial U\over\partial S}\right)_V} = S-{U\over T}$$
(Cryptic as it might seem, the identity $\left({\partial U\over\partial S}\right)_V=T$ is true, and moreover, is the definition of temperature.)

To bring this characteristic function to a more familiar appearance, we switch the sign (so we'll be looking after a minimum, and not maximum, as we did with entropy), then multiply it by $T$, since it is only going to be used in systems with $T=const$ anyway, and get the Helmholtz energy $F=U-TS$. That's what determines the state of equilibrium for fixed $(T,V)$.

Now let's make the final step. Luckily for us, $-S$ is the thermal derivative of $F$, hence the characteristic function in variables $(S,V)$ is
$$F-T\cdot\left({\partial F\over\partial T}\right)_V=F-T\cdot(-S)=F+TS=U$$
just as we were seeking to prove.

So it goes.

One more variable change from $V$ to $P$ will give us Gibbs energy, but that's another story.