How can price discrimination benefit both consumers and producers?
Basically, it's because producers get to sell more and consumers get to buy at prices they can afford.
There are three degrees of price discrimination, in Microeconomic Theory.
First degree is when each unit can be sold at a different price, what some might name one-to-one sales (or market). This is very uncommon (though might happen with club memberships' fee, for example) and is named also "perfect price discrimination".
Second degree is when the seller differentiates their products so that consumers will decide where they fit, while third degree is when the product is not differentiated, but the consumers are allocated into categories.
In these two cases, from one way or another, consumers will find what suits their needs and is more easily affordable, while the company (seller) will reach out more easily to a greater demand, that is, if prices were not discriminated, probably their number of customers would be lower.
Think of it like this: it is better to have people buying a can of soda for $2 and not buying the $5 two-liter bottle than simply not buying the $5 two-liter bottle.