As someone who's exploring when to stick to roots and when not to, I've given this a lot of consideration. First, I notice that most of the jazz bassists I admire don't stick to strictly playing the roots of the chords and that their lines are frequently more interesting than someone who reads a lead sheet as gospel. But, I suspect that most of these players have developed such a deep understanding of functional harmony and have such great ears that they generally know when and how they can break the rules. Not always; sometimes after transcribing someone, I found that I really didn't like their choice of notes but that's my personal subjective opinion. For all I know, the player wasn't all that thrilled with what they played then either - not their best work; even Ray probably had some off nights.
As
@DoubleMIDI said, learning when and how to break to "roots on one" rule takes a lot of experimentation and willingness to fail, but, I think, eventually leads a bassist to a more sophisticated sense of harmony and basslines.
I've been counseled by teachers I respect a great deal to "for the moment, play as inside as you can". I didn't get a chance to ask them why, but I think it goes back to the old saw "your outside is only as good as your inside". Ultimately, I think it's important to be able to play interesting, very supportive lines and interesting, less supportive lines and all shades in between, and then experiment and listen to the masters to learn what's appropriate. The keyword being "interesting".