Are you saying the "Turn Passcode Off" option is grayed out in your iPhone's settings? There are many requirements that must be met in order to do so. You must be connected to Wi-Fi or mobile data. You must not have Stolen Device Protection activated. You must not have Screen Time restrictions enabled.
Make sure those are all met, then you can erase your entire iPhone all at once with an easier route, in Settings > General > Transfer or Reset iPhone > Erase all Content and Settings. In addition to removing the passcode, it will also remove other pertinent information such as Find My, iCloud services, and many more.
What to do before you sell, give away, or trade in your iPhone or iPad - Apple Support