Real World Examples
When I updated my MacBook to the newest version of Mac OS X, v10.6 Snow Leopard, I didn't want to do an in-place upgrade from Leopard to Snow Leopard (which preserves your files, but also makes for a less-stable system). I wanted instead to install the OS on a clean, formatted drive. But since I sync my iPhone with the MacBook, I needed to keep my iTunes library in-tact so I wouldn't have to restore the iPhone to factory specs in order to sync after the new installation.
Another common experience where this might arrise is purchasing a new PC or Mac. If you want to begin syncing your iPhone with the new system, moving your iTunes library to the new computer will keep the iPhone syncing without a system restore (and maintain music, videos, etc. if you use the "Keep iTunes Music Folder Organized" option in the Preferences > Advanced window).
What You'll Need
The best way to move files from a old system to a new system is with an external hard drive. This will not only speed up the backup-and-restore process, but also allows you to have a backup of your entire iTunes library for safe keeping, or to easily perform future backups.
If you don't have an external hard drive, I recommend a portable solution like the Western Digital My Passport; these small drives are available in capacities ranging from 250GB (gigabytes) to 1TB (terabyte), more than enough space for most iTunes libraries. And, since they are powered by the USB port, you won't need a separate power adapter to use them.
For best backup and restore results, you should use the "Keep iTunes Music Folder Organized" option in the Preferences > Advanced window in iTunes. This keeps all of your music, videos, podcasts, etc., stored in a single folder (and its subfolders), making for an easier and more complete backup.
Rather than combine the backup procedures for Windows PCs and Macs in the same tutorial, I'm going to split the instructions into separate tutorials. To begin, select the move you're going to make:
Move iPhone from Old Mac to New Mac (Including Reinstallation of the OS)
Move iPhone from Old Windows PC to New PC (Including Reinstallation of the OS)
Move iPhone from PC to Mac (Coming Soon)
Move iPhone from Mac to PC (Coming Soon)