Variational principles and free-boundary problems