Fish live in balance with the minerals and salts in the water. These can be measured collectively as TDS, Total Dissolved Solids.
In fresh water there is almost no sodium chloride, but there can be many different minerals.
Fish cells need a very specific ratio of water: minerals (and salts).
Fresh water fish metabolism is geared to getting rid of excess water that enters their cells via gills and other soft tissue.
Fish from very soft water, low TDS need to keep pumping out a lot of water.
Fish from hard water, high TDS also need to keep pumping out water, but not so much.
Marine fish are the opposite. Water keeps trying to leave their cells. They need to hang onto the water and get rid of excess minerals, and especially salt.
When a fish is stressed they have a harder time to keep on removing the excess water. At this time adding something to the water to raise the TDS can ease the amount of work the fish needs to do to pump out the excess water. Sodium chloride will do this.
But it is only effective if the fish have not been in salted water. They need to be in water similar to what they evolved in, and their body needs to be able to do the work it was designed for while the fish is healthy. Then, if they get sick, you can add a small amount of salt to help out. If the salt was in the water all along their body gets used to doing less work. Then, when they get sick, you cannot help them by adding salt.
It is not specifically the salt, but the change
in TDS that is helping the stressed fish.
This osmotic regulation is also why, when you do water changes, you want the mineral levels in the water to match the tank. This is also one reason for fish to need time to acclimate to a new tank. If the mineral level they were used to in the store was rather high, and your tank has much softer water the fishes' metabolism is not geared to getting rid of the increased amount of water that enters their cells, especially when they are stressed by the capture and transport.
Sodium chloride or other source of chloride (for example, calcium chloride) can reduce the amount of nitrite that enters the fishes' system. When nitrite enters the blood it makes the blood less effective at carrying oxygen. (look up methemoglobinemia). Do enough water changes to keep the NO2 under 1 ppm and add sodium chloride at the rate of 1 teaspoon per 20 gallons of tank volume. When you do water changes add enough salt to maintain that dose. For example, a 5 gallon water change would get 1/4 tsp of salt. When the nitrite problem is resolved quit adding salt. Regular water changes will remove it.
Sodium chloride can kill certain fresh water parasites. Similar to the osmotic regulation that fish do, single celled and small multicelled organisms also live in balance with their water. But they may not be as good at handing changing levels of minerals and salts. If you increase the salt level sharply the fish may have some stress, but the parasite may die.
Salt Against Ciliates