The Israelites, being mammals, were partial to a bit of water. Not constantly or anything, just every now and then. It kept them from getting parched. So, after rambling around a place called Rephidim (located in the wonderful travelling location of modern-day Sharm el Sheikh) for a while they began to get an awful case of dry mouth and started asking Moses for some water. Being the kind of man that he was and — more importantly — having a magic stick, he struck a rock with his cane and water came pouring out.
In the Bible this sounds pretty impressive. Thirsty people wander around an arid desert desperate for a bit of juice and their chosen leader, as if my magic, knocks some water out of a rock. In reality though, science has this one covered. Moses was obviously something of a geologist and understood that soft porous limestone can retain loads of water within its craggy frame . A sharp crack to its outer crust might just release all the beautiful liquid beneath.
In fact, water is pretty predatory when it comes to limestone. The sedimentary rock is extremely soluble and because of this fun fact we get things like caves, potholes and the wonderfully named gorges. The area near Mount Sinai where Rephidim is supposed to have been based is also a haven for porous limestone rock.