Backing Up and Wiping Data
Always, always, always make a backup before you install a new ROM. In only about 5 minutes, it will take a full snapshot of your current setup as well as your data and settings (a "Nandroid backup"), which you can restore should something go wrong (or if you just don't like the new ROM). You can restore from a backup directly within ROM Manager, or via your custom recovery. Note that a backup is compatible only with the custom recovery that made it--for instance, you need to be in Clockwork recovery in order to install one of your Clockwork backups, and the same is true with SPRecovery. Clockwork creates backups in the /clockworkmod/backup/ directory on the SD Card (which you'll want to remember for deleting old ones). Once the phone is in recovery mode, you can find the backups under the Nandroid option.
Whether you should use 'Wipe Data and Cache' (the other option that ROM Manager will ask you about when you're installing a ROM) depends on a couple of variables. If it is your first time flashing a custom ROM (for example, going from stock Android to CyanogenMod), you should definitely wipe. If you are performing a major upgrade within a ROM (such as going from CyanogenMod 5 to CyanogenMod 6), I highly recommend that you wipe. If you are conducting a small, incremental upgrade (for instance, going from CyanogenMod 6.0 to CyanogenMod 6.1), you probably do not need to wipe, although sometimes it may help the handset's system run more smoothly. Flashing other files (such as flashing a new keyboard file or flashing a custom theme for your ROM) does not require a wipe.
Protecting Apps and Settings
You're probably asking one question right now: "Won't I lose all of my apps and settings if I wipe?" The answer: Not really. When you wipe and install a new ROM, you will see the same setup process you went through when you first got your phone. Once you enter your Google account info, though, not only do your contacts and calendar appointments all start flooding back, but so too do most of the apps you have downloaded (though you may have to open the Market to start this process). It's best to just let your phone sit there, undisturbed, for 10 minutes or so, giving it a chance to redownload and install all of those apps. Some other things, such as your wallpaper and a few (but certainly not all) of your system settings, will be restored, too.
A side note: Because of legal restrictions, some ROMs (including Cyanogen) do not come prepackaged with Google's proprietary apps (Gmail, Calendar, and the like). Again, ROM Manager makes taking care of this problem easy. When you select your ROM for downloading, the utility will ask if you want to install GApps. Check the GApps box, and they will download and install separately.
But...all of the data on your apps is gone! You were just about to beat Angry Birds, and now you have to start over! Worry not, my friend--that's why you should first turn to apps such as Titanium Backup and My Backup Pro.
For root users, either of those two programs can back up all of your apps and their data, storing it on your SD Card. Be aware: You must make the backups before you wipe and install a new ROM. Once your phone is running your new, clean ROM, simply download Titanium Backup or My Backup Pro (whichever one you used) if the app hasn't already been restored to your phone, and it will find your backups on the SD Card. You can then restore the data to the apps you want returned to their previous state. You can also use this approach to install apps again, if they didn't download from the Market.
Note: If you're making a larger change in ROMs (from one ROM to another, or from CyanogenMod 5 to CyanogenMod 6, for example), it's a bad idea to use Titanium to restore the system settings. These systems are liable to be set up very differently from each other, and that can cause a lot of problems. Setting your phone's system up again (restoring ringtones, notification settings, and the like) is a bit of a pain; but considering that your app data will be restored with Titanium, getting things back to how they were before won't take you too long. Don't risk borking up your phone's system.
Continue to Part II of our custom-ROMs primer, where we'll cover kernels, choosing the right ROM, and custom themes.