I first noticed a glimmer of light at the edge of the display, along the side. Examining more closely, I could see that the display was bulging slightly away from the case. Touching the display made it show a shimmering rainbow. I'd seen this before. That time I took the iPhone 5 to the Apple Store and they replaced the phone. This time when I took the phone to Apple, they reminded me that it was out of warranty. They said I could spend $100 to replace the display, but if the battery were bad then I'd be out the $100 and would still need a new phone. They wouldn't replace the battery. Since I suspected that the battery was indeed bad, I thanked them, went home to do some online research and discovered iFixit. iFixit seemed like a perfect solution, and as it turned out, it was. The repair took much less time than I spent hanging around near the Apple Store waiting for an appointment for them to tell me that there's nothing they can do.
I found two iFixit instructions. There's a video and also a web page document. The two sources are not exactly alike and it is helpful to study both and compare. Now the phone works and the edge of the display is properly hidden by the case. The display lies flat and shows no rainbows.
I worked on a plastic serving tray to help ensure that no parts escaped. iFixit offers a magnetic mat, but I improvised a substitute by using large refrigerator magnets from my refrigerator. These are those large magnetic ad sheets that are sometimes handed out by advertisers on phone books. If your refrigerator is covered with them grab a couple for this job. Just turn them over to expose the magnetic backing and you can place screws and other parts on it and they'll stay put.
I advise against trying to pry the battery out with the plastic opening tool. There are too many places where they caution about damaging adjacent components and they don't mention other spots where you could also damage something by using it as a fulcrum against the opening tool. Instead, there's a built-in plastic tab for removing the battery. You're less likely to break anything but you still have to be careful with it. Warm the back of the phone slightly with a hair drier to soften the adhesive a bit. Then pull the tab firmly upward, just enough to put some tension on it. It won't yield immediately and pulling harder will probably only break it. Just maintain the firm upward pressure and be patient. In a few moments, you should notice that the battery has suddenly pulled loose. Once it has yielded, you may still need to pry carefully with the plastic opening tool to finish removing the battery. A bulging battery is more difficult here since the distended bag around the battery finds more ways to stay stuck. Pulling the battery out with the plastic pull tab may leave the tab a little bit disheveled where it spreads out under the battery, so before installing the new battery, rearrange the legs of the tab so it lies neatly under the new battery.
The written instructions note that one of the screws holding the display plug retainers is non-magnetic to avoid interfering with the compass. Observe where this screw came from so you can put it back in the same place. However, the non-magnetic screw presents another problem: the magnetic screwdriver in the iFixit kit helps in removing and reinstalling the other screws but doesn't help with this one non-magnetic screw. Here you can use an old trick of "gluing" the screw to the screwdriver to help reinstalling this screw. Many substances have traditionally been used for this: soap, beeswax, etc. I used liquid plastic modeling cement. Just the tiniest amount on the tip of the screwdriver is sufficient for this screw. A single drop is way too much--wipe off the excess. The glue holds the screw on the tip of the screwdriver as you maneuver it into place and once you've tightened the screw the screwdriver detaches easily.
A swollen battery sometimes bulges out the back of the case as well as the display. This condition can be detected by laying the phone flat on a tabletop and giving it a spin. If the phone spins freely then the back of the case is bulging. An iPhone 5 should lie flat on a tabletop. The bulge can be corrected while you have the display off and the battery out by turning the case over and pressing carefully in the center of the case, just enough to flatten the back of the case. You may be surprised at how soft the aluminum is, it doesn't take much force to bend it.
Just because the display is bulging doesn't necessarily mean it must be replaced, regardless of what they may tell you at the Apple Genius Bar.