Welfare is value minus cost, for every unit sold/bought.
In a world where one unit of X good is sold, it would go to the highest bidder. The second unit would go to the second highest bidder and would cost more to produce (marginally) than the last unit.
If you carry this logic forward, at some point the next unit's marginal benefit (to the consumer) will be equal to the marginal cost (to the producer)**. The last consumer flipped a coin when purchasing since she got the same profit from purchasing and not purchasing.
Similarly, the producer also was indifferent between producing and not producing the last unit.
What if we supply ONE MORE unit than the equilibrium price? It would mean that the marginal cost exceeds the marginal benefit. The world and the individuals transacting are worse off after this transaction because the costs exceeded the benefit. This is known as dead weight loss.
To consumers: benefit is how much they were willing to pay for a good/service
MINUS what they had to pay/trade-off to obtain it (price). On the margin, this
is the net benefit of the **next unit** bought.
to producers: how much a unit is sold for (price) MINUS what it cost to
produce. On the margin, this is the benefit of the **next unit** sold.
Revenue is similar to this except it does not take into account the cost of production. So if my total revenue is \$100 and selling the next unit would get me to \$105 total revenue, my marginal revenue for that unit was \$5. Regardless of how much the next unit cost to produce.