Were you testing your water parameters before the death? If you were, and the kit was reading everything fine, then its possible the kit was giving false readings. A second kit or bringing it in to compare results with a lfs is a good idea when seeing problems.
How long has your tank been running? Is it possible that you didnt have a strong cycle? Or that your cycle crashed if you had one to begin with.
What type of flow is in the tank? I normally would use a tiny low flow filter, tiny submersible pump, or a air-stone turned way down located close to the surface. A feeder ring (air tube with a coupler is a easy way to make one) helps to keep high surface tension at a minimal in his hang out areas. ~my first betta in a community tank didn't make it due to flow (I was to dumb to know at the time)
The reality is some fish just aren't going to make it, and its possible he was doomed from the start. Since he seemed in good health its possible that something else that you couldn't know happened. Such as he was raised in high ph water, and you having a normal ph for bettas was a bad idea. Its hard to say but we all try to prevent such things from happening.