CVS Pharmacy Inc. and Walgreens Boots Alliance Inc. agreed to pay more than $10 billion to settle thousands of lawsuits by states, cities and counties alleging the retailers contributed to the nation's opioid crisis.