Baptism (like all Sacraments) is an outward and visible sign of an inward and spiritual grace (that’s the old Baltemore Catechism’s definition of “Sacrament”).
God gives us these visible signs because they teach us about the inward grace. Baptism uses water as a sign (symbol) of rebirth.
There is no reason why God could not have chosen another sign (maybe milk - as it gives life to newborns). The ritual is not what gives life - it is God who gives us life through the indwelling of the Holy Spirit. Exactly how that works - nobody knows.