Open Settings, and select System.
Select Reset options.
Select Erase all data (factory reset).
Select Reset Phone or Reset Tablet at the bottom.
You'll be asked to confirm, select Erase Everything.
Your device should reboot and may show a progress screen indicating that it is erasing the data.