No matter how I try to keep conditions ideal, losing a fish is going to happen at some time or another.
When I notice a fish acting strangely, the first thing I do is observe the others in the tank. Are they all acting strangely? Or just that one?
If they are all acting as though they are in distress, there could be something wrong with their environment. The heater might have malfunctioned and is either getting the water too hot or allowing it to grow cold. If painting occurred nearby or a carpet was cleaned or cleaning vapors got into the air, their water may have become contaminated.
In that case, the best thing to do is fix the problem (for example, if the heater is malfunctioning) and change some of the water (if it has become contaminated.)
More likely, one particular fish might be in distress. I have small hospital tanks in which I can isolate fish who are ill. There is a practical reason for this. First, it prevents others from getting ill. Second, it allows me to medicate the fish in a smaller environment. Because my angels live in tanks that are 60-70 gallons, that requires a lot of medicating. And if the other fish are not ill, I am forcing medicines into their bodies when they may not need it. Placing a sick fish into a smaller 10-gallon tank allows me to concentrate solely on getting that fish well.