In one of the largest opioid settlements reached by a standalone company to a state, Walgreens agreed to pay $500 million in a case New Mexico brought.