Unfortunately, if you forget your passcode, there’s no way to unlock the iPhone without erasing the data. However, regular backups ensure that you can restore your information.