I'm not so sure about cannabis specifically, but psychedelics in general played a role in the early development of many cultures, where shamans went into psychedelic trances to receive "divine inspiration". Some, like 20th century shaman Terrence McKenna, believe that getting stoned is actually the way we humans seperated ourselves from apes during our early development.
Today, traditional forms of shamanism are still practices by specific cultures on every continent. Examples of psychedelics used in such traditional contexts include peyote, psilocybin mushrooms, uncured tobacco, cannabis, ayahuasca, Salvia divinorum, Tabernanthe iboga, Ipomoea tricolor and Amanita muscaria.
During the 1960s, Timothy Leary popularized the used of psychedelics outside traditional shamanic contexts. Since the bloom of the 1960s counterculture, substances like cannabis, LSD, mescaline and many others have become widely used among philosophers, artists, scientists, engineers and entrepreneurs, in spite of their usual illegal status.
For example, Albert Hofmann took LSD together with Ernst Jünger. Neuroscientist John Lilly was an avid LSD user, and he introduced it to Richard Feynman. Steve Jobs took LSD up to 15 times from 1972 to 1974, according to official statements. Aldous Huxley took both mescaline & LSD, and described both experiences in respectively "The Doors of Perception" and "Heaven and Hell". Microdosing LSD on the job has been common among Silicon Valley software engineers. Among Cambridge researchers, the microdosing of LSD been common as well, according to a 2004 interview with Francis Crick.
Being far less potent than LSD or mescaline, cannabis is used much more widely and it's use in a recreational context has become about as mainstream as the recreational use of alcohol among millennials in many countries.
What a psychedelic (any psychedelic, including cannabis) does to the mind, is opening it up. It breaks down a person's preconceived ideas and allows ideas to enter the mind that were inconceivable to that same mind before. For example, it allows a religious person to take a less biased look at Atheism but also allows an Atheist to take a less biased look at religion. Or it allows a racist to see other races without prejudice, but also allows an anti-racist to see a racist without prejudice.
So, psychedelics break down not just the barriers in our own perception, but also the ones that prevent us from looking at each other as equals. How exactly this impacted philosophy, science, engineering or art as a whole, is very hard to estimate. This is particularly difficult since most of these substances are illegal and therefore few people address their use of such substances in public discourse.
Nevertheless, it's undeniable that they played a significant role in the development of the relativist perspectives on reality like those we find in existentialism and postmodernism. Because, really, if there's one common theme throughout psychedelic experiences, it's the notion that literally everything is relative and that the universe is ironic at its very core.
The following text, desribes the core principles of Discordianism, which is a semi-serious semi-parody take on religion, that was clearly fueled by LSD when it was penned down in 1963 and that perfectly illustrates what I mean be the notion that everything is relative and that the universe is ironic :
The Aneristic Principle is that of apparent order; the Eristic
Principle is that of apparent disorder. Both order and disorder are
man made concepts and are artificial divisions of pure chaos, which is
a level deeper than is the level of distinction making.
With our
concept-making apparatus called "the brain" we look at reality through
the ideas-about-reality which our cultures give us. The
ideas-about-reality are mistakenly labeled "reality" and unenlightened
people are forever perplexed by the fact that other people, especially
other cultures, see "reality" differently.
It is only the
ideas-about-reality which differ. Real (capital-T) True reality is a
level deeper than is the level of concept. We look at the world
through windows on which have been drawn grids (concepts). Different
philosophies use different grids. A culture is a group of people with
rather similar grids. Through a window we view chaos, and relate it to
the points on our grid, and thereby understand it. The order is in the
grid. That is the Aneristic Principle.
Western philosophy is
traditionally concerned with contrasting one grid with another grid,
and amending grids in hopes of finding a perfect one that will account
for all reality and will, hence, (say unenlightened westerners) be
true. This is illusory; it is what we Erisians call the Aneristic
Illusion. Some grids can be more useful than others, some more
beautiful than others, some more pleasant than others, etc., but none
can be more True than any other.
Disorder is simply unrelated
information viewed through some particular grid. But, like "relation",
no-relation is a concept. Male, like female, is an idea about sex. To
say that male-ness is "absence of female-ness", or vice versa, is a
matter of definition and metaphysically arbitrary. The artificial
concept of no-relation is the Eristic Principle.
The belief that
"order is true" and disorder is false or somehow wrong, is the
Aneristic Illusion. To say the same of disorder, is the Eristic
Illusion.
The point is that (little-t) truth is a matter of definition
relative to the grid one is using at the moment, and that (capital-T)
Truth, metaphysical reality, is irrelevant to grids entirely. Pick a
grid, and through it some chaos appears ordered and some appears
disordered. Pick another grid, and the same chaos will appear
differently ordered and disordered.
— Malaclypse the Younger,
Principia Discordia, pages 00049–00050
The following quote is also a good illustration the kind of mindset one develops from taking psychedelics :
We all must try to understand what is happening. We need to try to
understand what is happening, and in my humble opinion ideology is
only going to get in your way.
Nobody understands what is happening. Not Buddhists, not Christians,
not government scientists. No one understands what is happening.
So, forget ideology. They betray. They limit. They lead astray.
Just deal with the raw data and trust yourself. Nobody is smarter than
you are.
And what if they are? What good is their understanding doing you?
People walk around saying, "I don't understand Quantum Physics, but
somewhere somebody understands it." That's not a very helpful attitude
towards preserving the insights of Quantum Physics.
Inform yourself. What does inform yourself mean? It means transcend
and mistrust ideology. Go for direct experience.
What do YOU think when YOU face the waterfall? What do YOU think when
YOU have sex? What do YOU think when YOU take psilocybin?
Everything else is unconfirmable rumor, useless, probably lies. So,
liberate yourself from the illusion of culture. Take responsibility
for what you think and what you do.
— Terrence McKenna