Bearing in mind that the iPhone might require your passcode in these situations:
- Turn on or restart your device
- Press the Home button or swipe up to unlock your device
- Update your software
- Erase your device
- View or change passcode settings
- Install iOS or iPadOS Configuration profiles
if you forgot your passcode, see what you can do:
Given that to remove the existing passcode you must connect your device via USB to a computer (a Windows PC running the latest iTunes version, or a Mac, which can run iTunes or Finder, depending on the macOS installed on it), and keeping in mind that if you don't have a backup all data will be lost on that device (except those that you eventually synced to iCloud), pay attention to the specific gestures that you need to perform while connecting your device to the computer.
These are the instructions to re-gain access to your iPhone/iPad:
If it is an iPhone:--> If you forgot your iPhone passcode - Apple Support
If it is an iPad:--> If you forgot the passcode on your iPad, or your iPad is disabled - Apple Support
Or, watch this support video about the same matter (for both iPhone and iPad):
https://www.youtube.com/watch?v=7s8-zLG9ySQ
Regards
Giulio