My iPhone 5s shuts down when it has remaining battery
You have essentially eliminated software as a cause by restoring the OS. If it happens consistently around the same percentage remaining, you likely have bad cells in the battery. Batteries cannot be repaired, so you must either have it replaced at an Apple Store or authorized repair center, or consider ordering parts and tools and doing it yourself if you have some technical proficiency (e.g., https://www.ifixit.com/Guide/iPhone+5s+Battery+Replacement/19239).