Moody's agreed to pay nearly $864 million to settle with U.S. authorities over its ratings of risky mortgage securities.