Dear Student ,
A gas has higher entropy. Entropy will add additional degrees of freedom to molecules, by the absorption of energy. When we condense the gas into a liquid, the heat of condensation that is given off, reflects, in part, the lowering of entropy and the retrieval of the energy once tied up in the entropy/ The loss of entropy also allows for more order, allowing the EM forces to act more efficiently.
Going from liquid to a solid, does the same thing. The liquid has higher entropy and when it freezes this disorder is lowered. This frees up energy, while the loss of entropy/disorder in the liquid, allows the higher degree of order that is needed to overlap orbitals via the EM force.
Thus gas has more potential energy and solid has negative potential energy .
Regards