Cannabis suggests we evolved with it, see Endocannabinoid system or whatever it is called. However, I do believe it is random. Magic mushrooms have been around for longer than we have, so it's probably just chance that they make us trip (which enabled lots of mental healing power).