The iPhone's passcode feature is an important way to keep prying eyes out of your personal data, but what if you forgot your iPhone passcode? If you forget your password and enter the wrong password six times, your iPhone will inform you that it has been turned off. Also, depending on your settings, entering the wrong password too frequently may erase all data on your iPhone.
If your iPhone is turned off, the bad news is that there is no way to bypass the password and just restart your iPhone; if it were possible anyone could do it and it would overcome the password security point.
The exact behavior of your iPhone depends on how you set it up when you forget your password. By default, there is no password at all. However, Apple points out the following regarding forgotten passcodes.
If you repeatedly enter the wrong password, your iPhone will be shut down for a long time before you can try again. After too many unsuccessful attempts, you won't be able to try again until you reconnect to the computer it was last synced with.
Another way to do the same is to use Apple's Find My iPhone feature, which allows you to track your iOS devices and - at worst - reset them if they are stolen and cannot be recovered. You can use this option for your iPhone that is turned off.