You can go to Settings>General>Reset and use "Erase All Content and Settings" which will securely wipe everything including the operating system so when it is finished which can take some time, you will need to do a restore to whatever firmware you want and then set it up as a new device.