Its really hard to say what killed him? You say that you got him home and put him in a tank with filtered water, a lot of filter system's use chlorine in them so if you didnt use water conditioner then that is real bad. The 2nd thing is he goes from the store to a bag so thats stress, then to the little tank you had thats stress. So he didn't even get to adjust and then you got a bigger tank. And did you use water conditioner in this tank? and what kind of water? So your fish was getting stressed out bad and a stressed fish gets sick sometimes. And then when you add bad water quality to it then they really get sick.
Some people say that ICK is always on a fish, and always in the tank. It just need's the right condition's to come alive.
Some people say ICK come's from poor water condition's, and some say it is from the fish when he gets down and out like we do sometimes.
ICK is very easy to cure in some cases people have cured the tank just by raising the temp to 85, some add fresh water aquarium salt. And some do both, raise the temp and salt... In all cases it has worked out for the people.. I had ICK on my 55, and I like to be safe then sorry. So I put the temp on 85, the aquarium salt and added copper safe treatment. And it was all gone in 3 days..
On bettas, because there so tough and hardy, I like to put them a 1.5 gallon hospital tank and treat with quick cure. Me and other breeders have done it for years and it's always work out fine. Everyone has there own way so.... In your case I would of treated the betta in the display tank. Because if you went to put him back, you no he is not going to catch it again... the whole tank would be treated. And you still need to treat the tank before putting another betta in there...
Im sorry you lost him it can be heart breaking, Specially when you have had them for 3 or 4 years...
Get the tank clean and ready plus do a lot of research and by that time you will be ready for a new guy I hope..... Because out there somewhere is a betta that needs a good home.