The only way is to erase your iPhone, which removes the passcode. This will delete all your data unless you have a backup.
1. If the Find My Phone is turned off, use Finder or iTunes to put your iPhone into Recovery Mode and choose restore to reset it.
2. If the Find My Phone is turned on, use the Find My app on another Apple device or iCloud.com to erase it remotely.
3. Use an unlock tool like TunesKit iPhone Unlocker, download it on your computer, and connect your iPhone with a USB cable to unlock it.
After erasing, you can set it up as new or restore from a backup. You will need your Apple ID password to reactivate it.