Under US copyright law, it is illegal to profit from someone else’s intellectual property. This means you cannot write a story using someone else’s characters or setting or plot and sell it, unless you are writing an officially licensed tie-in novel or you’ve renamed the characters and changed them just enough to claim plausible deniability. (In fan fiction circles this practice is called "filing off the serial numbers," and it’s what E.L. James did when she changed her Twilight AU (alternate universe) fic Masters of the Universe into Fifty Shades of Grey.)
If you want to distribute fanfic that is explicitly labeled as fanfic — say, a novel that's set in Harry Potter’s universe or that involves characters from The Lord of the Rings, you must do it for free on sites like Archive of Our Own or FanFiction.net.
Beyond the copyright issues, discussions of fan fiction often have a moralizing subtext: Isn’t it a little lazy, even fundamentally dishonest, to steal someone else’s concept for your story? Why don’t you just think up your own idea? Characters, after all, belong to the authors who invented them: "My characters are my children," says George R.R. Martin, of Game of Thrones fame. "I don’t want people making off with them, thank you."
Outlander author Diana Gabaldon is harsher: "I think it’s immoral, I know it’s illegal, and it makes me want to barf whenever I’ve inadvertently encountered some of it involving my characters."
It is, of course, entirely reasonable for authors and creators to discourage fan fiction for profit, especially when their livelihoods depend on preserving their copyrights. No one wants to be the schmuck who allows all kinds of fans to create all kinds of fan fiction and subsequently becomes the penniless creator of a beloved shared universe, much adored and without a dollar to show for it.
But until extremely recently, stories were born out of shared universes all the time. It was rare for anyone to create a wholly original story when there were already so many fun and exciting characters and legends and plots available to play with. Why dream up another wise and heroic king when you could write a new King Arthur story? Why tell the tale of another endless war when you could put a new spin on the Trojan War? Historically, writers constantly borrowed characters and plots from all sorts of sources and turned them into new stories. Those stories became yet more stories; that was just how storytelling worked.
And some of those stories went on to become some of the most beloved pieces of literature in the Western canon. Here are five great works of literature that are also fanfic.
1) The Aeneid, Virgil
The Aeneid, which tells the story of the Trojan hero Aeneas — the ancestor of the Romans — draws from a number of different sources, but its most prominent is The Iliad. In Homer’s account of the Trojan War, Aeneas is a minor character who is repeatedly spared by the gods because of his great destiny. Virgil picks up where Homer leaves off, at the fall of Troy, and follows Aeneas — now a great hero — from Troy to Italy, where he conquers the Latins. In fanfic terms, The Aeneid is Marty Stu post-epilogue Homerfic.
2) The Divine Comedy, Dante
The Divine Comedy manages the hat trick of qualifying as Biblefic, Homerfic, and Virgilfic. Sure, it’s a monumentally well-crafted allegory of the soul’s approach to the divine and more or less invented a new form of poetry, but it’s also a self-insert fic in which Dante, fanboy extraordinaire, gets to write about himself meeting Virgil and Homer and all his other faves and have them all tell him how much they like him. I mean:
They turn’d to me, with salutation kind
Beckoning me; at the which my master smiled:
Nor was this all; but greater honour still
They gave me, for they made me of their tribe;
And I was sixth amid so learn’d a band.
This is the 14th-century Italian equivalent of writing yourself onto Star Trek's Enterprise and having Gene Roddenberry high-five you and tell you he loves your work.
3) Le Morte D’Artur, Sir Thomas Mallory
The legend of King Arthur dates back to at least the eighth century. By the time Sir Thomas Mallory wrote Le Morte D’Artur in 1485, its source material had been transformed from a Welsh legend of magic and conquest to a romance cycle of chivalry and courtly love developed by French troubadours. It was on the basis of centuries of accumulated stories and traditions that Mallory created his magnum opus.
Mallory’s version of the King Arthur story combines French romances with Middle English sources into a single coherent saga, creating a framework in which the most popular elements of Arthurian legend — the sword in the stone, the quest for the holy grail, the love story of Lancelot and Guinevere, and Arthur’s defeat by his son Mordred — could coexist in one narrative. Mallory conceived of almost none of the story himself, but he integrated all of its parts together in a way that made sense and was compelling.
Le Morte D’Artur became one of the primary sources for later writers when they decided to craft their own retellings of the Arthurian legend. The most famous example is T.H. White's The Once and Future King, which later became the source material for Disney’s The Sword in the Stone.
4) Hamlet, William Shakespeare
Shakespeare wrote very few original plots. For most of his plays, he drew on existing narratives and developed them as he saw fit. Hamlet, no exception, is based on a Norse legend composed in the early 13th century, about a prince named Amleth who feigns madness to escape the wrath of his murderous, usurping uncle.
Shakespeare seems to have based his Hamlet most heavily on a play by Thomas Kyd that's now known as the Ur-Hamlet. Kyd’s play has since been lost, but we know that it featured a ghost who cries out, "Hamlet, revenge!" — much as Shakespeare’s ghost instructs Hamlet, "If thou didst ever thy dear father love / … Revenge his foul and most unnatural murder."
Shakespeare scholar Stephen Greenblatt has argued that Shakespeare’s greatest change to the legend of Amleth was to remove the motive: Amleth’s feigned madness is part of a perfectly reasonable revenge plan, but Hamlet’s madness is famously opaque, which helps Hamlet develop its psychological complexity.
5) Wide Sargasso Sea, Jean Rhys
Wide Sargasso Sea is a postcolonialist prequel to and critique of Jane Eyre. Written from the point of view of Mr. Rochester’s first wife — called Bertha in Jane Eyre and Antoinette in Wide Sargasso Sea — the book turns Charlotte Brontë’s gothic madwoman in the attic into a fully realized tragic heroine.
Where Jane Eyre’s Bertha is "savage," "devilish," and unspeaking, Antoinette is intelligent and perceptive, driven slowly to madness both by her husband’s cruelty and by a society that considers her to be her husband’s property. While the book can stand on its own, it depends on its intertextual relationship to its source material to reach its full emotional resonance.