$U$ (or actually $S$) is only relevant for an isolated system. This is not the case, for example, when you keep the temperature constant, since then heat must flow from the environment to your system (or vice versa) for $T$ to remain fixed.
But let's say the system you are interested in is small compared to the environment. Keeping track after all the thermodynamics of the surroundings is difficult, so we want to somehow treat the system alone without having to think all the time on what is happening outside. The way to do it, in the case of thermal contact only, is to define the Helmholtz free energy
$$F=U-TS$$
Here $U$ is the energy of the system, $S$ is its entropy but $T$ is the temperature of the environment (and it is fixed since your system is so small so that practically it has no effect on it). When $F$ is minimized, it can be shown (see here) that the entropy of the system + the environment is maximized, which is the condition you would expect for a system in thermal equilibrium.
Similarly, if your system can only exchange volume with the environment, the quantity that is minimized is known at the enthalpy
$$H=U+PV$$
In the case of both heat and volume exchange, you would use the Gibbs free energy
$$G=U-TS+PV$$
There is also a mathematical-inclined argument for this. You know that
$${\rm d}F=-S{\rm d}T-P{\rm d}V$$
so the natural variables of $F$ are $T$ and $V$, i.e. $F=F\left(T,V\right)$. It means that $F$ is the right function to use if you can control both $T$ and $V$, which is the case for a system of constant volume in contact with a thermal bath. In the other cases
$${\rm d}H=T{\rm d}S+V{\rm d}P\Longrightarrow H=H\left(S,P\right)$$
and
$${\rm d}G=-S{\rm d}T+V{\rm d}P\Longrightarrow G=G\left(T,P\right)$$
You can clearly see which variables you can control and consequently which situations each thermodynamic potential fits. This mathematical trick of changing the variables of your function is known as the Legendre transformation. This is exactly the same as the relation between Lagrangians and Hamiltonians in classical mechanics.
To finish with an example, when treating liquid-gas phase transitions, it is customary to use the Gibbs free energy. This is the right thermodynamic potential since your system can exchange both its entropy $S$ and volume $V$ with the outside, such that the variables you control (the environment) are the corresponding conjugate variables - the temperature $T$ and the pressure $P$ respectively.