The energy of the formation of a solution is divided into three energies (enthalpies #DeltaH#) as shown in the figure below:
#color(gray)("Image source: Zumdahl textbook")#
The enthalpy is the solution is given by:
#DeltaH_("Soln")=DeltaH_1+DeltaH_2+DeltaH_3#
If #DeltaH_("Soln")<0#, the solution will form and if #DeltaH_("Soln")">>"0# (large positive) the solution will not form.
However, if #DeltaH_("Soln")>0# (small positive) the solution will form thanks to the increase in entropy #DeltaS>0#.
for example, the #(DeltaH_("Soln"))_(NaCl)=3(kJ)/(mol)# which is small positive. The solution forms as we know, since #NaCl# is soluble in water.