Rare-earth nickelates exhibit a remarkable metal-insulator transition accompanied by a symmetry-lowering structural distortion. Using model considerations and first-principles calculations, we present a theory of this phase transition which reveals the key role of the coupling between electronic and lattice instabilities. We show that the transition is driven by the proximity to an instability towards electronic disproportionation which couples to a specific structural distortion mode, cooperatively driving the system into the insulating state. This allows us to identify two key control parameters of the transition: the susceptibility to electronic disproportionation and the stiffness of the lattice mode. We show that our findings can be rationalized in terms of a Landau theory involving two coupled order parameters, with general implications for transition-metal oxides.