A friend was disappointed and confused because her newly-purchased goldfish all died after just a few days, and she had no idea why. I kept fish for years, and I remember having such experiences myself. I will pass on the advice I gave to her, in case you are thinking of getting fish, or if you are having problems with "mystery deaths", as well:
Three things can kill fish: poor water quality, disease, and predators. "Mystery deaths" are usually due to water quality, as you would probably notice signs of disease or predation. This is either because there is chlorine in the water, the pH balance is wrong, ammonia is building up in the water, or there is not enough oxygen.
1) To get chlorine out of water, just "age" the water by letting it sit around in a bucket for a couple of days before you put it in the tank, and the chlorine will dissipate. Also, that will bring it to room temperature, so it will not shock the fish.
2) To check the pH balance, get a test kit, which will come with some treatment drops to adjust the pH. Most goldfish prefer a pH of 6.5 - 7.0. If you need to adjust the pH, do it slowly, because a sudden change can also kill your fish. Also, test your tap water to see if it has a high or low pH to start with--then you will know how water changes will swing the balance.
3) The most likely problem is ammonia buildup, because freshwater fish, and especially goldfish, pee a lot, and I think they would have died sooner if it were a chlorine or pH problem. Make sure your filter has some material that absorbs ammonia. There are ammonia test kits, too; you can check to see if the levels are safe. If they aren't, best thing to do is change the water, but not all of it: Only change about 10% of the water at a time (you should do this once a week, anyway). Just make sure to use the water that has been aged in the bucket, so there is no chlorine.
4) It's also possible that there wasn't enough oxygen in the water. Yes, fish actually breathe oxygen, they just do it after it has dissolved in water. To properly oxygenate the water, make sure your tank has a large surface area (that's where the air gets in--if your fish are all hanging out at the surface, they might not be hungry--they might be gasping for air! If there's not enough oxygen in the water, some fish get desperate enough to gulp air at the surface).
Having an air bubbler helps a lot, but the surface area is very important--goldfish bowls are very bad, because they have a small surface area when they are filled up. If you have a bowl, make sure the water level is below the upper curve of the bowl so that the surface area is larger. But it's really best to avoid bowls altogether - they are just too small. The only fish that does okay in a bowl is the betta or Siamese fighting fish, because they breather from the surface. You should still make sure the bowl is much bigger than the kind they sell them in. It's cruel to keep a fish in such a tiny container.
5) Lastly, make very sure not to get any foreign matter or substances in the water. Soap is extremely deadly to fish, so don't clean around the tank with soaps, cleansers, or sprays. Make sure that little children don't have access to the tank, as a toddler may try to feed the fish with inappropriate items. When decorating the tank, use only items that are designed for doing so, as paint or substances from non-aquarium-safe objects could poison the fish. Even the approved decorations and equipment should be thoroughly washed (no soap! Just hot water and maybe a bit of bleach - thoroughly rinse) before putting in the tank.
This probably sounds like a lot of work, and it is. Fish aren't just for decoration--like any other pets, you really have to be willing to take care of them. It's best to buy a good book on aquarium keeping, and to get the tank ready in advance before purchasing the fish. Good luck!
Image Credit » http://pixabay.com/en/fish-goldfish-freshwater-fish-235784/ by Hans