‘If you are interested in stories with happy endings, you would be better off reading some other one,” starts The Bad Beginning, the first instalment of Lemony Snicket’s A Series of Unfortunate Events. With that sentence alone, first published 20 years ago, Snicket – AKA author Daniel Handler – hooked a very particular audience. After all, there’s nothing kids want to do more than prove adults wrong.

Released in 1999, when the adolescent book market was dominated by Harry Potter, A Series of Unfortunate Events provided even darker fare in a field full of orphans and murder. Narrated by Lemony Snicket, whose sworn duty it is to retell the “true” events of the three Baudelaire children, Violet, Klaus and Sunny, the 13 books see the unlucky orphans evade kidnapping and murder in the wake of their parents’ death by arson. It was dark and difficult, and appealed to morbid and precocious children by toeing the line between child and adult fiction in a way nothing ever had before. It was controversial – some schools restricted access to the books over their suggestions of incest and swearing – but this only enticed children more.

In the 20 years since The Bad Beginning, A Series of Unfortunate Events has sold more than 60m copies around the world and survived an unsuccessful film adaptation in 2004, to eventually land a three-season Netflix series, which gave room to do the books enough justice to please even the most pernickety of fan. That is no mean feat – A Series of Unfortunate Events’ fans, now adults, are incredibly pedantic.

Morbid and precocious ... Neil Patrick Harris as Count Olaf. Photograph: Joe Lederer/Netflix

What made these books different? In 13 books over seven years, Handler invited participation, which begets an obsessive fanbase. As the Baudelaires discovered that their parents were part of a mysterious organisation called VFD and worked to get to the bottom of what that means, the reader was there with them, trying to decipher the hints and clues. Some secrets were explained in spinoffs, but enough was left unanswered to give kids work to do on fan forums. One mystery involving a sugar bowl was so enduring that there were endless threads dedicated to it; when I interviewed Handler in 2017, he said that “if you watched as the series came to a conclusion, you could basically see an entire internet being built around people curious about the sugar bowl”. The recent Netflix series finally offered a neat explanation – but some fans (me) didn’t necessarily want one at all.

Perhaps A Series of Unfortunate Events is so special simply because Handler saw children as people. He only wrote a children’s book after his publisher, passing on his first novel, The Basic Eight, told him to. Thinking all children’s books were “crap”, he set out to write something he would want to read. He took his readers seriously. Where Harry Potter was aggressively simplistic, Handler used devices such as alliteration and repetition to the point of absurdity, while referencing everything from Shakespeare to Melville. Books are an essential part of the plot: our heroes love reading and use literary references as code, whereas “wicked people never have time for reading. It’s one of the reasons for their wickedness”.

While the series appealed to adults, the books always prioritised children. The Baudelaires are shown to be innovative and independent, as many child heroes often are, but Handler reminded us that they shouldn’t have to be so resourceful. A Series of Unfortunate Events isn’t just about the bravery of the children, but the failures of adults. It’s about the grey area between bona fide villains and useless good guys who don’t speak out about the abuses they witness. We are taught, too, that even good adults, such as The Bad Beginning’s Justice Strauss or The Vile Village’s Hector, will let their own self-interest get in the way and fail the children in their care. There is no easy division between good and evil, as one character notes: “People aren’t either wicked or noble. They’re like chef’s salads, with good things and bad things chopped and mixed together.” As the series progressed, it began to deal with moral relativism, as the orphans commit the same atrocities as their enemies to different ends. There was always room for multiple readings, with Handler revealing in 2007 that the Baudelaires are Jewish. “I think there is something naturally Jewish about unending misery,” he told Moment. Part of the series’ longevity is due to the fact that it is endlessly interpretable, easily revisited by fans now in adulthood.

A Series of Unfortunate Events entered my life when I was just seven. I was a voracious reader, and a terminally lonely one, partly as a result of the former. It taught me that my own thoughts could be trusted, that my impulses to read and make things were not unusual, to find joy and sanctuary where there was none. It didn’t have happy endings, sure, but it reinforced what I already knew: they’re not always what we need.