You can factory reset your iPhone and wipe all its data in the Settings app. If you don't remember your password, you can use iTunes instead.
If you need to reset your iPhone to factory settings to resolve an issue, you can back it up to iCloud first and then restore it to keep your data.
If you absolutely need to factory reset your iPhone or iPad but don't have the credentials for the registered Apple ID, there are a few things you can try. There are quite a few reasons someone may ...