Battery health affects value, but not in the linear way people assume. The relationship is a cliff rather than a slope, and knowing where the cliff is changes what you should do about it.
Where to find the number
Settings, Battery, Battery Health and Charging. The figure is Maximum Capacity, shown as a percentage of what the battery held when new.
Read the actual number rather than estimating from how the phone feels. Perceived battery life is affected by screen brightness, signal strength and what you have been doing, and it is a poor proxy for the real figure.
The 80% cliff
Between 100% and about 85%, the effect on resale value is small. Buyers treat that whole band as normal.
Below 80%, the effect becomes substantial, for two reasons. Apple's own interface starts describing the battery as significantly degraded, which is a label a prospective buyer can see. And below that threshold the phone starts behaving noticeably worse, shutting down early and throttling under load.
So the difference between 81% and 79% costs more than the difference between 95% and 85%. That is counter-intuitive and it is the single most useful thing in this article.
Should you replace it before selling?
Almost never, and this is where people lose money trying to gain it.
An official Apple replacement costs more than it adds to a buyback offer. You would be spending real money to move a phone from one band to another and recovering less than you spent.
A third-party replacement is worse. The phone permanently records that it contains an unknown battery part, it may lose battery health reporting entirely, and buyers discount for both. A phone with a cheap replacement battery frequently sells for less than the same phone with an honest, tired original.
What to do instead
Tell us the real number. Battery health is the most common cause of an offer changing after testing, and it is entirely avoidable, because it is one figure on one screen that takes ten seconds to check.
If you are keeping the phone a while longer, the things that actually slow degradation are avoiding heat, avoiding overnight charging at 100%, and leaving Optimised Battery Charging switched on. Heat is by far the biggest of the three, and a phone charging under a pillow is the worst case.
The short version
Check the real number, do not replace the battery before selling, and expect the price to move meaningfully only if you are under 80%. Above that, it is a small factor competing with model, storage and condition.