After they left Egypt the Children of Israel crossed the Reed Sea and needed water. They got to Marah after 3 days (at which there were bitter waters) and complained as mentioned in Sh'mot 15:23. Moshe puts wood in the water and the water turns sweet.
In 15:27, they travel to Eilim at which there is plenty of water. They leave Eilim (perek 16) and complain about food so the mon descends. By 17:1 they get to Rephidim and there is mention of a lack of water. Moshe is instructed to strike the rock and water comes from it.
The gemara states that the people were accompanied by a well during their wanderings ("He elaborates: The well was given to the Jewish people in the merit of Miriam;") and Rashi connects it to the actual rock that Moshe struck. This means that before the events at Rephidim, there was no water accompanying the people. They had no water unless they happened upon naturally occurring sources.
I'm not sure why Miriam, specifically, is connected to water (though the description of bitter waters as מרים seems like a natural bridge) nor do I understand why, if it was in the merit of Miriam, Moshe had to strike the rock at all the first time, but my question is if it was in Miriam's merit, why did it start at this particular point and not earlier, when the people also needed it?