Neither enthalpy nor entropy alone can decide the spontaneity of a process.

For example, evaporation of water from oceans is an endothermic process $(\Delta H \gt 0)$, which clearly violates the fact that a system aims for minimum energy, yet this process is spontaneous (or naturally occurring).

To determine the spontaneity of a process the Gibbs-Hemholtz equation was introduced. This combines the effects of both enthalpy and entropy for determining the spontaneity of a process.

$\Delta G=\Delta H-T\Delta S$

A system generally aims for two things; minimum energy and maximum probability to be found in the universe (or more entropy). Therefore, for a spontaneous process, $\Delta H \lt 0$ and $\Delta S \gt 0$, Which gives an overall negative change is Gibbs energy.

For a spontaneous process, $\Delta G$ is negative.