Stomata is an opening of a plant for transpiration. The main process of the plant is photosynthesis and for this stoma small opening in the leaves help in intake of carbon dioxide and release of oxygen.
However, during this process, their is the loss of water due to gas exchange.
In short supply of water, the closed stomata help in maintaining the water level in the plant thereby avoiding the evaporation and loss of water content. For photosynthesis: These openings are small and are managed during the daytime to ensure less water loss.