Yes, and no... If you do a factory restore of your iphone, it will completely wipe your iPhone's history away. That's why you want to make sure that you have a working backup of your iPhone data before doing the restore. Before you do a Restore, iTunes will ask you if you would like to make a backup of your iPhone, which I would highly suggest you do.
After the Restore has completed, and you sync your iPhone to iTunes for the first time, you will have the option to setup your iPhone "as a new iPhone" or "Restore from the backup of:" your iphones backup copy. When you restore from the backup, you should retain all your previous settings, text messages, apps, etc.