If you mean the iPhone passcode, you cannot view or recover the current passcode
Erase the iPhone using Recovery Mode
Connect the iPhone to a Mac or PC
Put the iPhone into Recovery Mode
Open Finder on Mac or iTunes on Windows or older macOS
Select the iPhone when it appears
Choose Restore
Set up the iPhone again
Restore from an iCloud or computer backup if available
If you forgot your Apple ID password, go to iforgot.apple.com
If Find My iPhone is enabled, erase the device from iCloud.com or the Find My app
If you need help, contact Apple Support
