How to recover a Screen Time passcode
When you set up Screen Time, if you associated it with an Apple ID you can follow these instructions to reset it→If you forgot your Screen Time passcode - Apple Support or watch this companion video:
If you did not associate an Apple ID when you first created the passcode the only option is to restore your phone to factory settings and do not restore a backup, as the backup contains the screen time passcode→Restore your iOS device to factory settings - Apple Support