They'll do free replacements if it's a known defect, and especially if it's widely experienced. Even Nintendo does that if they sniff a potential class action and want to avoid it.
Usually only after a very large public spat about how they are not being responsible for the problem. They have in the past denied problems that were widespread (board warp, keyboard, etc.) until either lawsuits or extreme push-back from the community - usually when they release a new product with those mistakes removed and it's impossible to deny them any more.
Painting Apple out to be a company that "does the right thing" without being forced to do so isn't accurate.
Even without that.
I won’t go into details, but they went out of their way quite a few times, without me having to pay a dime, and no defect whatsoever was involved.