If you've ever gone to the beach and let a handful of sand flow through your fingers, you've probably noticed that sand is made up of lots of tiny bits of rock that have been broken down over time, thanks to the elements. And if you've been to more than one beach, you may have observed that the sand you encountered at each different beach was different. It's no surprise that the composition of sand varies in different geographic areas, but there are certain common minerals found in most sand, such as quartz, a very hard and durable mineral.
Mineral hardness is measured by a standard called the Mohs scale. Quartz has a Mohs rating of 7, with 1 being the softest and 10 being a mineral of perfect hardness, like a diamond. Quartz is chemically inert, meaning it keeps its original form and doesn't react with most substances, so it changes little with time and weathering (including barrages of floodwater).
Porosity is another important attribute of sand. The trait refers to a substance's ability to let light, air or water flow through it. The more porous something is, the more water can pass through it. Sand is a coarse-textured material, and the coarser the texture of the material, the less porous it is. Not a bad quality if you're talking about a material that's used to help control flooding.
In a sandbag, the sand itself doesn't hold back the water; there are several different things going on within and around the bag. Floodwaters, filled with fine particles like silt and clay, are flowing into the sandbags. The sand basically "catches" these particles. The clay and silt fill the gaps in the sand, actually making the sand a better barrier. As more water flows through, the sand gets muddier and muddier, which is a good cycle, as it allows less and less water to seep through the bag. In addition, the sandbag is getting heavier and heavier, so if it's placed in the right area, the floodwaters won't wash the bag away.
It may have been coincidence and convenience that caused us to create sandbags in the beginning, but composition and a bit of geology have kept this tool around.