If you know the passcode, go to Settings
Tap General
Tap Transfer or Reset iPad
Tap Erase All Content and Settings
Enter the passcode when prompted
Enter your Apple ID password if asked
Confirm the erase
Wait for the iPad to reset and restart
If you do not know the passcode, use Recovery Mode with a computer
Connect the iPad to a Mac or PC
Open Finder on Mac or iTunes on Windows or older macOS
Put the iPad into Recovery Mode
When prompted, choose Restore
Wait for the restore to finish
Set up the iPad again after it restarts
