Matter can exist in three states namely, solid, liquid and gas. Under a given set of conditions of temperature and pressure, the most stable state of a substance depends upon the net effect of two opposing forces: intermolecular forces and thermal energy.
Intermolecular forces tend to keep the constituent particles (atoms, ions or molecules) closer, whereas thermal energy tends to keep them apart by making them move faster.
The competition between molecular interaction energy due to intermolecular forces and thermal energy determines whether a given substance under a given set of condition is a gas, a liquid or a solid. At sufficiently low temperature, the thermal energy is low and molecular forces are very strong.
As a result, the intermolecular forces keep the constituents so close that they cling to one another and occupy fixed positions and the substance exists in solid state.