The reason you need to enter your password is because you need to sign out of Find My iPhone before you can be allowed to reset your iPhone.
Before deleting, go to:
Settings -> Apple ID (Your Name) -> iCloud.
Go to Find My iPhone and disable (you must enter your code)
After, go to:
Settings -> Apple ID (Your Name)
Select sign out at the bottom.
Now - Close all apps and restart your iPhone.
Then your iPhone 5S is not connected to your Apple ID and you are ready to reset your iPhone to factory settings. Go to:
Settings -> General -> Reset. Select Delete All Content and Settings
Hopefully your iPhone does not freeze now.