When you work with cancer patients, you have to know that the morphine dose you're giving could be the one that pushes them over the edge. But not to give the pain medication -- allowing the patient to suffer needlessly -- isn't the right thing, either. It sounds like this man had made his peace with his upcoming death, and was just ready. He may have been denying his 10/10 pain for days so he could get his affairs in order and say goodbye to his family with a clear head. Once that work was done, he was ready to let go, admit to the pain and receive medication for it.
You didn't do anything wrong. You don't medicate pain if the patient tells you he isn't having any. When he does admit to having pain, you called the provider and got him some pain medication. You called the family and got his daughter there in time to say goodbye. You followed his wishes. You did the right thing. Yes, the morphine may have hastened his demise, but he died comfortably and not in 10/10 pain. The provider was aware of that possibility when she gave the order. Withholding the morphine wouldn't have prolonged his LIFE, it would have just extended the dying process. That's torture. You did good.
It sounds like you could use a little debriefing. Is there a nurse educator, a mentor, or someone you could talk to about this? An Employee Assistance Program where you work? If not, journalling helps a lot. Just put pen to paper or fingers to keyboard and write for 20 minutes. If you don't know what to write about, write that. Whenever I do that, I find that by the end of 20 minutes, I've written out the question that was bothering me, and if I don't have the answer yet, I'm always halfway there.