why does the surface of liquid at rest tries to occupy the least surface area?
The most stable state of any system is usually that which posses the least amount of energy. The system consisting of a liquid will tend to minimize the surface area because such configuration will have minimal energy. This phenomenon is referred to as surface tension. In brief, surface tension is the energy required to increase the surface area of a liquid by a unit of area. We can also say that surface area is the tendency of liquids to contract and resist external force.
In order to explain, then, why liquids have the tendecy to minimize surface area, we only need to look at surface tension at the molecular level. When you have a liquid, whether a drop of it or a container full of liquid, we can always classify the molecules in two categories. First one would be the exterior molecules, those at the surface, or interphase between the atmosphere and the liquid. Second one would be the interior molecules, those contained in the bulk of the liquid.
Molecules of the liquid attract each other. The interior molecules are being pulled or attracted in all directions. However, exterior molecules are only attracted by those beside them, or those below them (in a container) or those towards the center (for a drop). The result of this would be a lower energy for the interior molecules (being attracted by balancing force -- since the pull is from all directions). The result would be the tendency of the exterior molecules to minimize its energy. This is possible by contracting -- being pulled inwards due to the imbalance of forces. The result of this, in terms of surface, is the minimization of the liquids area.