Chumash Torah Sheleima (Bamidbar 20:1) brings the Midrash Esfah that says as follows (Free translation):
And Miriam Died There: She alone died from all the women that left Egypt, since the women did not die in the desert. As it is stated (Yehoshua 5:4) "All the people that came out of Egypt, that were males, all the men of war, had died", but not the women.
And why did she (i.e. Miriam) die? Because of the well that was given because of her. It was not possible that the she should still be around and the well that was in her honor would depart.
Another answer, because she was equal in greatness to Moshe and Aharon, as all 3 were the "good providers of the Jews" (Talmud Taanit 9A), and it was not just (proper) that they (Moshe and Aharon) should pass away while Miriam remained. Therefore she passed away first.
The Kli Yakar (Bamidbar 20:4), while not addressing the question, says that Miriam dies so that the well that was in her merit would stop flowing. This is because there were people in Kadesh who didn't want to enter the land and once they water stopped they realized they couldn't stay there.