The reason that they died was probably overstocking. Unfortunately, there is a lot of deception about fish care out there, that ends in a lot of losses
Before you get a betta, you should read about the nitrogen cycle and do a fishless cycle on your tank. Basically, all fish poop, which creates ammonia, which kills fish. This is what probably killed the goldfish and loach. In order to keep out friends safe, we have to establish a "cycle" in the tank, which turns the ammonia into nitrIte via bacteria, which also kills fish, so another bacteria builds to turn the nitrIte into nitrAte. NitrAte kills fish at high levels, so weekly water changes keep the levels down.
Doing this cycle with fish in the tank sometimes harms them, so I think it's best to do a fishless cycle. You could buy some Pure or Clear ammonia at a hardware store. Make sure that the only ingredients are water and ammonia. Surfactants will kill fish. You can dose this in the tank to establish the cycle. There are some wonderful guides on the internet about how to do this well.
You may also want to invest in a liquid test kit. API makes a great one. This will allow you to monitor the levels off ammonia, and will tell you when the cycle is complete. When it is done, the 2.5 gal could make a great home for your new fish!! Most mistakes are made from misinformation, so be sure to do plenty of research and ask all the questions you want!