I had the water heater replaced in my old condo, before putting it on the market to sell. I think it was the original water heater, so it was over 30 years old at this point. I figured that would help it sell easier.
The water heater was also in a really awkward spot. You accessed it through a closet in one of the secondary bedrooms. If it went bad, it would have made quite a mess, so this one might have been a good candidate for pre-emptive replacement.
In my old house, the water heater went bad, back in 2010. It got a pinhole leak. Unfortunately, one of those little clear plastic dress shirt collar stays had gotten on top of hole for the drain pan, so I didn't realize it was leaking, until that drain pan filled up and overflowed. Luckily it was in the laundry room, and didn't really do any damage.
Current house has its water heater down in the basement, where it wouldn't do much harm if it did start leaking, so I don't give it much thought. I guess I should check the date on it, to see how old it is, though. I bought the house in 2018, and know the house went through a huge renovation in 2008, so I always just presumed it was replaced then. But, who knows?