In order to solve the issue, you will need to erase everything on your device using iTunes, Find My iPhone, or recovery mode. After that, if you have a backup, you can use it to restore your data and settings back.
First, connect the device to your computer and open iTunes. If it is not asking for a passcode, iTunes should automatically sync your device and create a backup. After the process is completed, select Restore from iTunes backup option when you will be asked to set up your device.
The second option is Find My iPhone service. Navigate to iCloud to see if you enabled the feature. If it is enabled, press All Devices, select your iPhone and click the Erase option. In this way, you will erase the content on your device and its passcode. After that, restore the most recent backup.
The third solution is to use the recovery mode. Turn off your device and disconnect all cables. Press and hold the Home button and connect your device to iTunes. If the iPhone is not turned on automatically, turn it on. Wait for Connect to iTunes message and click OK when iTunes detects the device. After that, restore the backup. For further details, check the official Support page.