See chapter 15 in “Gravitation” by Misner Thorne and Wheeler and also page 253 in Gauge fields, knots, and gravity by J. Baez
When we get to gauge theories we will see that MaxwellÄs equations are a special case of the Yang-Mills equations, which describe not only electromagnetism but also the strong and weak nuclear forces. A generalization of the identity $d^2=0$, the Bianchi identity, implies conservation of “charge” in all these theories - although these theories have different kinds of “charge”. Similarly, we will see when we get to general relativity that due to the Bianchi identity, Einstein's equations for gravity automatically imply local conservation of energy and momentum!
page 96 in Gauge fields, knots, and gravity by John Baez