Restoring your iPhone to its original factory settings is a way to repair any damages you've done to the phone by downloading unauthorized software. It's not guaranteed to fix your problems, but it is your best bet.
Here's a step-by-step tutorial that shows you how to restore your iPhone.
Note: If you recently purchased a new iPhone and are looking to set it up, you should read "How to Set Up a New iPhone." This will guide you through the process of setting up a new iPhone.
Let's get started: The first step is to look at your iPhone and see if this is really necessary. Restoring your phone will delete all of the data on it, including any pictures, music, videos, and contacts. The screenshot above is the home page of my iPhone after I decided to jailbreak it. My iPhone was in need of repair.
Let's move on to step two.