Check for water damage.
A phone may seem good on the outside, but there could be some water damage lurking beneath the surface. You’ll want to check for the Liquid Contact Indicators (LCIs) on the device and see if they’ve been activated. This post from Apple will tell you where to look for the LCIs on specific iPhone models.
Don’t be fooled: an LCI will only be triggered if it comes into contact with water or a liquid containing water. Humidity or temperature changes won’t activate an LCI.