If you forget your iPhone passcode, you can use Face ID/Touch ID, a professional iOS unlocker like imyPass iPassGo, or use Recovery Mode with iTunes or Finder on a computer to unlock your iPhone.
To unlock iPhone with Face ID/Touch ID, simply let the device scan your face or fingerprint for recognition.
Using an iOS unlocker like imyPass iPassGo requires connecting your iPhone to a computer, downloading the software, and following on-screen instructions to remove the passcode.
You can also erase your iPhone via iCloud if you have Find My iPhone enabled, or use the built-in 'Erase iPhone' feature on the lock screen if your iPhone is running iOS 15.2 or later.