Legal opiates wouldn't be laced with fentanyl. They'd be tightly regulated. And it would probably be packaged in ways that wouldn't require injection. That sort of packaging would probably be part of the regulations. No one wants needles lying around.
If users know exactly how strong & how much they're taking then it should greatly reduce overdoses. Some will still happen but, as a society, we've decided a certain amount of alcohol overdoses are acceptable. Opiate overdoses would get similar consideration.