The second by second, minute by minute update you see on your device representing the amount of charge remaining is only an estimate. Sensitive electronic devices, iPhones, camera, etc. can be damaged if too low a voltage is sent through the sensitive electronics such as the processor and other sensitive integrated circuits. When your iPhone detects the voltage is dropping too low, it turns off the iPhone, thus protecting the sensitive electronics.
Why isn’t the estimate more accurate? You can change things to both increase battery life and decrease battery life, such as turning down the screen brightness, turning off WiFi, etc. But ultimately, it’s designed to protect your iPhone.