It is very hard to say what the cause is.. I only can give you an example of one of my own experiences and of what i think the probable cause is..
I feed regularly froozen food, like bloodworm, daphnia, krill etc.. With this always comes a load of planaria eggs.. Then if you do not have any planaria eating fish the result might be a lot of planaria crawling through the tank.. Not realy a problem, but if it gets out of control it looks insightly. Now there is a product on the market called NoPlanaria, of which they state it is shrimp and fish safe, safe to most common snails and kills planaria. So i gave it a try to get give the planaria population a hard time. It worked like a treat with in the 3 given days, no more planaria to see, unfortunately my snails probably where not so common, all died.
Anyway as it looks the fish and amano shrimp were not affected by the product.. All was ok at least for the first 2 weeks and then all shrimp one after another turned an ember color and died with a typical intoxication symptom.. A few weeks later i noticed the majority of Pygmaea Cory's suffering from finrot, so i had to treat the tank again with antibiotics, furtunately all survived, not all have their fins back yet but are healthy again.
Now what happend? Most likely, because it all happend shortly after the NoPlanaria treatment.. All dead planaria in the substrate started to rot as most like all baby snails did too. This will cause i very high amonia and nitrite bioload and maybe some unwanted bacteria explosian as well at the substrate level. Tho i checked regularly for the most common causes of shrimp intoxication, ammonia, nitrite or metals, but the tests never showed any off vallues in the water collumn. Still i suspect the NoPlanaria aftermath to be the cause, shrimps especialy amanos constantly turn over the substrate as cory's also constantly dig into it.. This activity creates a little microbubble of toxic substannes close to the substrate where the fish and shrimp are in. This toxic bubble obviously delutes while it mixes with the rest of the water column.. Anyway the long term effect is intoxication, deadly to shrimps, because they are very sensitive to this, less deadly to fish but still it makes them weak and susceptible to infections etc.
Very hard to proof theory, but still it fits chronological perfectly together because all occured with in 2 months after the NoPlanaria treatment and it was the first and last time i had any issues in this tank..
Anyway if your fish and shrimp are dying there is obviously something wrong in the tank.. What it is, i realy can't say with the information you provide.. It can be a number of things causing it.. 9 out of 10 times it is bad maintenance or adding toxics to the water.. Or introducing an infecton with new fish or materials..
Think back for your self if there is something you have changed or added in the past time, check all your equipment for any kind of malfunction (wrong temperatur??). Healthy fish are pretty resiliant, they ussualy get sick and infected if conditions are bad for longer periode and they become weak because of that and susceptible to a number of infections.. Do extra water changes and inspect your living fish closely for any signs of infection, like parasites, fungus or finrot etc.. A dead fish always looks unsightly and probably chunks bitten off or sucked uppon by some snails.. A dead fish only tells you it's dead, diagnose your living fish to find out if there is something wrong and treat them accordingly..
Good luck..