Shaping a plant root into an ideal structure for water capture is increasingly important for sustainable agriculture in the era of global climate change. Although the current genetic engineering of crops favours deep-reaching roots, here we show that nature has apparently adopted a different strategy of shaping roots. We construct a mathematical model for optimal root length distribution by considering that plants seek maximal water uptake at the metabolic expenses of root growth. Our theory finds a logarithmic decrease of root length density with depth to be most beneficial for efficient water uptake, which is supported by biological data as well as our experiments using root-mimicking network systems. Our study provides a tool to gauge the relative performance of root networks in transgenic plants engineered to endure a water deficit. Moreover, we lay a fundamental framework for mechanical understanding and design of water-absorptive growing networks, such as medical and industrial fluid transport systems and soft robots, which grow in porous media including soils and biotissues.