See the article If you forgot your iPhone passcode - Apple Support
If you enter the wrong passcode on your iPhone Lock Screen too many times, an alert lets you know that your iPhone is disabled. (Learn what to do if you see "[Device] unavailable" or "Security Lockout" on your iPhone or iPad.)
If you can’t remember your passcode when you try again, use a computer to put your iPhone in recovery mode. Recovery mode allows you to erase the iPhone, giving you access to set it up again.
After you erase your iPhone, you can restore your data and settings from a backup. If you didn't back up your iPhone, you can set it up as a new device and then download any data that you have in iCloud.
See Restore your iPhone, iPad or iPod touch from a backup – Apple Support