When prices are allowed to freely fluctuate they tend towards the market equilibrium. The equilibrum consists on a price level, and a quantity of product exchanged at which both the interests of producers and consumers, are equal. At such point, the market clears, and there are not shortages or surpluses, consumers maximize their utility and producers manage to maximize their profits too.
Prices function as signals that show what are the individual intentions and desires of the economic agents (households, firms and state).