If you've forgotten your passcode, Apple provides official recovery methods, which often involve putting your device into Recovery Mode and restoring it via a computer. This will erase all data on the device. If you have a backup, you can restore your data afterward. It's a safe and free option, though it requires that you have a backup.
A prompt will automatically appear on your computer screen stating there is a problem with the device.
It assists users who have forgotten their 4-digit/6-digit passcodes, Touch ID, or Face ID.