If a computer is severely infected with malware or has become too slow to use, a factory reset is the "nuclear option" to give the PC a fresh start.
Go to Settings > System > Recovery.
Click Reset PC.
Choose Keep my files. This removes apps and settings but saves your documents and photos.
Go to Settings > System > Recovery.
Click Reset PC.
Choose Remove everything. This wipes the entire drive. Ensure you have a backup of your data before choosing this.