Somehow NPCs can get stuck inside the well in Riften. I've seen it happen a few times with Imperial soldiers (or maybe guards). Most recently the solider stuck in there was an Imperial soldier from a world encounter (FormID started with FF). Riften is under Imperial control in my game, so previously I didn't bother to try to differentiate between a Riften guard and one of the identical non-guard soldiers. Unless there's something noticeably wrong with spawn markers or navmeshes, I don't really have anything to go on as far as why it happens. There's probably a chance it's engine related too.
Screenshot:
https://postimg.cc/hJsr7wYD