You must realize that most fish you see in stores were swimming around the vast ocean a mere week ago. As such, the stress of capture and transportation can wreak havoc with the biological processes of the animal.
The most important thing when buying a fish is to not be overcome by the buying impulse. Before buying any animal, you should ask 'Can I keep it happy'. Merely keeping the fish or invertebrate alive doesn't mean it is happy. Fifty goldfish may live in a 10 gallon tank, but they certainly won't be happy or healthy. Buying a fish you know nothing about and then asking if you can keep this fish happy is a very bad practice. Also, as hard as it is to say this, don't feel like you are doing a sick fish any favors by taking it home. If you have the room and time to nurture the sick fish, then I suggest you help out the environment and care for the sick fish rather than letting it die. However, if you are just going to place the fish into your main tank because you don't have the time or inclination to set a up a quarantine tank, then don't bother. It will only result in the death of the fish and the lightening of your wallet.
Once you decide on a particular fish, don't be afraid to ask the store to hold it for you. A good store will always hold a fish for you (don't patronize stores that won't!). Also, ask to see the fish eat. If the fish is healthy and eating, then it most likely is a good specimen. Finally, check the fish closely for spots, irregular patches, missing scales, and wounds. Torn fins will usually heal and are not much of a problem.