The settlement is the first of its kind to hold retail stores responsible for their roles in the opioid crisis, according to prosecutors.