Welfare economics is in the realm of normative economics. It is a study of how the well being of society is affected by economics. In order to objectively study welfare of society, economists use compensating variation, which means assigning a dollar value to welfare.
Having an understanding of welfare economics will help us to explore how different market settings affect our society and whether market competition is beneficial.
Consumer surplus is the benefit enjoyed by consumers, above and beyond the price paid for the good. It is calculated by the area under the demand curve but above the price of the good.
Similarly, producer surplus is the profit or benefit enjoyed by producers for producing with a cost lower that the price of the good. The surplus is equivalent to profit in the long run as there is no fixed cost. It is calculated by the area above the supply curve but below the price of the good.
The total social welfare derived from a good is the sum of consumer and producer surplus. At the market equilibrium, welfare is maximised as there is no other points that can derive more social welfare. If the market is producing at any other points besides the equilibrium, there will be a transfer of welfare, from consumer to producer or vice versa, as well as a loss of welfare, known as deadweight loss. Deadweight loss means that trades that can benefit the society exist but they are not happening.
(Reference: MIT OCW Principles of Microeconomics)