This is nothing to do with weight or costs. Using a 'zero bag' price with a surcharge allows them to advertise a flight for less, and many people will take that flight over one for twenty dollars more, without checking or realizing that the 'more expensive' flight gives them a free bag and the 'cheap' one charges forty dollars for a bag. It maximizes the chances that your flight shows up at the top when your flight is ordered by prices on the booking website.
Also, not everybody who takes the zero bag fare takes zero bags. Some will pay $50 for a bag, resulting in more profit for the airline.
The other factor is that a zero bag fare captures the people for whom price is a limiting factor - who will only make the flight if it costs them less than \$100. This gets the airline \$100 for the zero bag fare, which would otherwise have been $0 for an empty seat.