The Beverly Hills Cop star soared to fame in the 1980s at the height of the pair's drug addictions and says he's grateful he didn't give in to the same temptations that killed Belushi and contributed to Williams' depression battle.
Father of 10, Murphy told The Interview podcast: "I remember I was 19, I went to the Blues Bar. It was me, Belushi and Robin Williams.
"They start doing coke, and I was like, 'No, I'm cool'.
"I wasn't taking some moral stance. I just wasn't interested in it. To not have the desire or the curiosity, I'd say that's providence. God was looking over me in that moment."
Murphy added the tragic rise and fall of stars including the late Michael Jackson and Elvis Presley were "cautionary tales".
Belushi was killed by a heroin overdose at the age of 33 in 1982, while Williams took his life in 2014 aged 63 after years of drug and drink addictions.
Jackson was also killed aged 50 in 2009 by a tranquiliser overdose, while Elvis was found dead from a heart attack at 42 following years of prescription drug abuse.
Murphy, 63, told the New York Times: "When you get famous really young, especially a black artist, it's like living in a minefield.
"Any moment something could happen that can undo everything. It was like, all of this stuff is going on, and I'm totally oblivious.
"Now, at this age, I can look back and be like, 'Wow, I came through a minefield for 35 years'.
"How do you make it through a minefield for 35, 40 years? Something has to be looking over you."
Lifeline 13 11 14
beyondblue 1300 22 4636