As long as you stick with reputable sellers like LiveAquaria or BlueZoo (just to name what I feel are the 2 best) then I would say you have a higher chance of survival than from even a local fish store. Also LiveAquaria offers a 14 day guarantee on most items, which if a fish were sick when you got it chances are it wouldn't make the 14 days. I have only bought 1 fish online, from LiveAquaria, and it didn't make it past 10 days but a simple 30 second phone call and I had my refund on a $200 fish. Remember though, shipping usually cost $40-$50 so that adds quite a bit to an order and makes ordering a $10-$20 fish online not really worth it.
How they are shipped, overnighted FedEx in a styrofoam box with heat packs, and a bag of water with the fish inside, usually with a filler like packing peanuts to make sure it doesn't move around too much in the box. I have ordered many "clean up crews" (crabs/snails from places like reefs2go) online and those ship a lot easier, although in my experience ordering snails and crabs online you get micro sized critters where as at a local fish store they are usually much larger specimens. Some corals ship easy, others are much more difficult (SPS corals) but no matter what it is, fish, corals, or inverts, they are all shipped at some point in their life, whether it be from the ocean to wholesalers to stores or from breeders to stores.