Why does my Iphone shut down at 20%?

When I first got my Iphone 5, it would usually keep running until it got to about 8% battery. However, these past couple of weeks I'm starting to notice that it shuts down at around 20%.Is there a way to fix this problem?

Your phone is probably reading the battery levels wrong, it looks like it has 20% but in reality it may have 2 or 3% battery left about to die. You can try restoring it to reset the battery information and then let the phone discharge all the way and charge it back up again to see if that work. I wouldn't recommend charging the battery until its around 15-10% battery left as to make they battery last longer in the short term and long term.

You need to calibrate your battery

Calibrate your battery.

You need to calibrate your iphone battery:
use your iphone until it shuts down
leave it turned off for more than 2 hours
recharge it until it goes 100% and let the charger plugged in for 2 more hours
use your iphone again until the battery drains
recharge it until the battery is full