Well, I typed out an explanation, but then did a quick search to see if I could phrase things better. I am an aspiring marine biologist, but this fisheries scientist put it pretty well a year ago. I suggest you read his explanation.
"Fisheries scientist here. I am seeing a lot of incomplete or partially correct answers here. This might be more ELI15.
Freshwater fishes tend to have much higher concentrations of ions (like sodium) in their blood compared with the concentrations in the water. Their bodies are designed to expel large volumes of very dilute urine frequently. This works to their advantage in a freshwater environment because they are surrounded by water with low salt concentrations. So, just pee a lot and hang onto what little salts you have. They also have specialized cells in their gills to allow them to directly take up sodium and chloride from the water to fine-tune the salt balance in their blood and cells.
Saltwater fishes face the opposite problem. They need to maintain salt concentrations in their blood that are much lower than the surrounding environment. To do this, they actively drink water and form a highly-concentrated urine to expel the excess salts. They also actively expel salts at their gills.
So the basic freshwater strategy is to pee like hell and absorb salt. The basic saltwater strategy is to drink and hold it so they can absorb as much of the water (while leaving behind the salts) as possible. Put either of these fishes in the opposite environment, and these critical systems fail to function. The "pee like hell" strategy will quickly deplete cells of water in a saltwater environment, while the "drink and hold it" strategy will completely water-log them. These salt concentrations are critical to many bodily functions. Just think about what happens to people when they get dehydrated or, in some cases, drink TOO MUCH water. They are at real risk of death. Same for these fish.
What about things like salmon? Or sharks?
Many salmon and their relatives live in both fresh and saltwater at different points in their lives. Pacific salmon (e.g., Chinook salmon) are born in freshwater. They have nice, normal freshwater adaptations. However, when they reach a certain age and are ready to leave their rivers, they go through dramatic physical transformations during which they develop the necessary adaptations to live in a marine environment. When they are old enough, and are ready to breed in freshwater as adults, they undergo yet another transformation. This, and the energy required to to migrate and produce eggs/sperm, exacts such a toll on the fish that they almost always die immediately after spawning. Moving between fresh and saltwater is not easy.
What about sharks, like bullsharks? How do they move between fresh and saltwater? Sharks are very different from what people normally call "fish". They also have a completely different strategy for surviving in saltwater, which will inform us about how some survive in freshwater. Rather than deal with the threat of constant water loss by drinking saltwater and excreting the extra salt, a shark's blood is filled with urea (a nitrogen-based compound that makes your pee stink [EDIT: the stink is actually from the urea decomposing into ammonia; urea is odorless on its own]). In fact, they store so much of it that their blood ion concentrations are actually close to that of sea water. Sharks that can spend time in freshwater are able to expel excess urea (which is just a metabolic waste product, hence why it's in your pee) rather than retain it in their blood. This allows them to adjust the levels of dissolved ions in their blood so that they can flexibly move between salt and freshwaters.
Now, this doesn't cover everything (there are 25,000+ fish species), but hopefully it gives a more complete overview...
EDIT: There has been some confusion regarding my use of the word "fishes." My use of this word is completely intentional. "Fishes" has a particular use among ichthyologists and fisheries scientists. "Fish" can be singular or plural. We use it as a general plural, as in, "there are 20 fish over there." "Fishes" is used when one is discussing multiple types (species, genera, whatever), as in, "a red fish and a blue fish makes two fishes". When I say "fishes", I am referring to more than one type. When I say "fish", I am referring to multiple fish of the same type."
Some fish do, given a period when they can "transform" from one water type to another. Salmon are an example; they mostly live at sea but spawn way up in fresh water streams.
But the reason is how the salt itself interacts with gills, which are pretty much a fish's lungs where its blood exchanges oxygen and carbon dioxide as part of breathing.
Our human bodies need a certain balance of salt or they start having electrical problems. So if we ingest too much salt our kidneys try and filter it out, and if they don't - such as if we're on a liferaft at sea and drink sea water -
we go mad (the classic line "water water everywhere and not a drop to drink" comes from this).
Fish don't just DRINK water, they breathe it. So they get used to breathing salt water and their chemistry compensates for contact with all the salt, or they get used to breathing fresh water and their chemistry compensates for not enough salt.
Flip the switch too completely and too rapidly, and the fish dies because there's too much or tool little salt in its "lungs".
We often use freshwater as a treatment for saltwater fish and vice versa. Some fish live their lives, at different stages, in one then the other.
Some fish move back and forth on a more regular basis and some fish are either completely freshwater or completely saltwater.
So, when you put that saltwater fish into freshwater here is how it goes. Assuming you have matched the pH and temperature and have removed any other toxic compounds like chlorine, the fish is primarily dealing with a major change in the salt gradient between the inside of their body and the outside. Many parasites and bacteria cannot tolerate this rapid change and will “absorb” water until they rupture and die.
This is driven by osmosis where the water wants to be equally diluted with the “salts” on either side of a semi-permeable membrane (cell walls). The water begins to move through the cell walls and the parasite or bacteria are not equipped with a mechanism to deal with all of the water intruding and they explode.
Your fish on the other hand, is capable of dealing with this issue for various amounts of time depending on the species of fish. This time (think minutes in most cases) in the freshwater is a wonderful treatment for external parasites and is not a severe stress for many saltwater fish.
If on the other hand, you do not match the pH or other parameters then the reaction is very different and other chemical/biological reactions take place generally being highly stressful for the fish and usually killing it.