Unpredictable rainfall is an important risk for agricultural activity, and farmers in developing countries often receive incomplete insurance from informal risk-sharing networks. We study the demand for, and effects of, offering formal index-based rainfall insurance through a randomized experiment in an environment where the informal risk sharing network can be readily identified and richly characterized: sub-castes in rural India. A model allowing for both idiosyncratic and aggregate risk shows that informal networks lower the demand for formal insurance only if the network indemnifies against aggregate risk, but not if its primary role is to insure against farmer-specific losses. When formal insurance carries basis risk (mismatches between payouts and actual losses due to the remote location of the rainfall gauge), informal risk sharing that covers idiosyncratic losses enhance the benefits of index insurance. Formal index insurance enables households to take more risk even in the presence of informal insurance. We find substantial empirical support of these nuanced predictions of the model by conducting the experiment (randomizing both index insurance offers, and the locations of rainfall gauges) on castes for whom we have a rich history of group responsiveness to household and aggregate rainfall shocks.