Most things in use today from seasoning to medicine were discovered by accident. For instance Viagra was developed to be a blood pressure medication - turned out it was not very good at it but had an interesting side effect which is what it is primarily marketed for these days.
So what were they doing when they invented suppositories? And by reading the article at the link above what the hell were they doing when they figured out that this beaver's secretions smelled and tasted like vanilla and why it would be so much more effective than say vanilla extract?
Well... where it was discovered in the first place was in history (as in, several hundred years ago), by people whose life credo was "EAT ALL THE THINGS", because the other option was "starve to death". I imagine the leap to "hey, this stuff actually tastes great!" wasn't that big...
1. Vanilla, whether artificial or natural, is vastly cheaper to produce and obtain than castoreum. Where castoreum is used, it's used in minute quantities, and certainly never as a substitute for vanilla. And
2. I thought everyone knew about castoreum by now? Are we still shocked about cochineal bug dyes too?