John Perry Barlow, who has died aged 70 after a long period of ill health, started as a cattle rancher, wrote lyrics for the Grateful Dead, and then became a digital rights activist and a champion of free speech on the internet. His ideas captured the mood of a generation that believed people could reinvent themselves in a new virtual world with no government controls and no national boundaries.

And, by the way, where they could share digital music and movies without paying for them. As Barlow pointed out, digital goods, unlike physical goods, could be infinitely replicated at zero cost.

Having worked with the Grateful Dead, Barlow was one of the first to understand that, in an information economy, value is driven not by scarcity but by familiarity. This insight is the basis of “viral marketing”, and many of today’s free online services are based on it.

Barlow benefited from this viral effect, in that he is most commonly remembered – at least, outside the fraternity of Deadheads – for his sonorous, Jeffersonian paper A Declaration of the Independence of Cyberspace. He wrote it one night at the World Economic Forum in Davos in 1996, between bouts of drinking and dancing. It was a response to the arrogance and (digital) ignor- ance of the world’s leaders, and to President Bill Clinton’s foolish Communications Decency Act, which tried to ban offensive material online.

Barlow “zapped it off to [his] email list” – the hundreds of people who followed his public life – and it rapidly spread across the web like a rash. Some people criticised it for being naive, but its idealism was inspiring. The declaration’s huge success fitted Barlow’s belief in pronoia, which is the opposite of paranoia: it is the feeling that the world is secretly conspiring to help you. In reality, Barlow used his fame to help others. He had already co-founded in 1990 the Electronic Frontier Foundation, to fight governments in the courts, and he added the Freedom of the Press Foundation in 2012. He also worked to bring the internet to Africa, to promote biofuels in India, to clear mines in Vietnam and to legalise marijuana in the US, among other things.

In a Q&A on the Reddit conferencing system, he wrote: “I’m willing to accept it when someone calls me a good man. I’ve been working on that one quite consciously for a long time. And, outside of being a good ancestor, it’s my main ambition.” One of his 25 “adult principles” was: “Avoid the pursuit of happiness. Seek to define your mission and pursue that.”

Barlow was born in Sublette County in rural Wyoming, the only child of devout Mormons, Norman Barlow, a rancher and Republican state senator, and his wife, Miriam Bailey (nee Jenkins). At 15, he was dispatched to board at the Fountain Valley school in Colorado, where his roommate was Bob Weir, a dyslexic teenager from San Francisco. Weir was expelled – after which he bumped into Jerry Garcia in Palo Alto, and helped found the rock band that became the Grateful Dead – but the two young boys would become lifelong friends.

Weir dragooned Barlow into writing lyrics for Ace, his solo album project, which segued into writing lyrics for the Grateful Dead. The song Cassidy, from Weir’s album, became one of the Grateful Dead’s concert classics.

However, things took an un- expected turn in 1971, when Barlow visited the family ranch while heading back to California. His father had suffered a stroke, and died the following year. Barlow spent the next 17 years running the ranch with his mother, and writing lyrics while doing manual work.

One of the remarkable things about the Grateful Dead was that they encouraged fans to make bootleg recordings of their concerts. At the time, most bands used concerts to sell records. The Dead used recordings to sell concerts – they even set up their own mail-order ticket business to cut out the middlemen.

Barlow recognised the changing business model and analysed it in an essay, The Economy of Ideas, published in Wired magazine in 1994. He wrote that “the best way to raise demand for your product is to give it away,” and that was how Silicon Valley companies took over the web.

Pronoia helped again when Barlow started using The Well (or Whole Earth ’Lectronic Link), an online bulletin board based in San Francisco. It was the main meeting place for Grateful Dead fans, but it was also where Barlow first came across the digital-rights activists Mitch Kapor (designer of the Lotus 1-2-3 spreadsheet) and John Gilmore, from Sun Microsystems. The three men founded the Electronic Frontier Foundation in 1990.

Barlow had no technology training – he had graduated with a BA in comparative religion from Wesleyan University, a liberal arts college in Connecticut – and had been a rancher until he sold up in 1988. Now he was surrounded by hackers and uber-geeks. But he was an early adopter, a pretty fast learner and a larger-than-life communicator. He may not have had a deep understanding of the bits and bytes, but he could extract key ideas and convey them to a wide audience. As a self-described “free agent and peripheral visionary”, he communicated by writing for many outlets, including Wired, and by speaking at conferences worldwide.

His 1977 marriage to Elaine Parker, who stayed in Wyoming, did not survive the change, and they divorced in 1995. He wrote a memoir, Mother American Night: My Life in Crazy Times, which will be published in June.

Barlow is survived by his daughters, Leah, Anna and Amelia.

• John Perry Barlow, writer and activist, born 3 October 1947; died 6 February 2018