Swivels are used in fly fishing to keep your line from twisting. When you are fishing, the bait can often cause your line to twist. A swivel will prevent that from happening. Because some baits don't twist as much as others, you might be able to get by without a swivel for those.
Look for quality first and foremost. You want swivels that spin easily. Barrel swivels are cheap, but higher-quality ones have a ball bearing in them, turn with very little pressure and tend to be stronger than barrel swivels. Use them when fishing for hard-fighting fish, when you are trolling, or in any kind of fishing when the bait spins a lot.
When fishing for species that like to attack shiny objects, use a black or dark swivel. A bright silver swivel a foot up the line from the bait may attract the strike, so you won’t hook your fish, and your prey could actually cut your line. But you must use a swivel with some baits, otherwise the line will twist to much to be of any use at all. A swivel can also stop the lead and keep it away from the bait. You can, for example, thread a bullet weight on your main line and tie a swivel to it, then attach a leader from a few inches to several feet long. This keeps the bait away from the lead and can be used for live bait as well as plastic worms.
Regular swivels have a line attachment loop at either end. Three-way swivels that have three loops for the line. These work well for bait walker rigs and any other time you need to tie more than one leader to a swivel. They're often not as strong as normal swivels, so make sure you get a quality three-way swivel if you’re going after big prey on your fly fishing trip.