I think even great stories can inspire the creation of great fanfics. I've written and read my fair share of fanfiction and at least in my experience, great fanfictions don't solely rely on the quality (or lack of quality) of the referenced source material. It relies on the imagination and storytelling skills of fanfiction writers who are inspired to write such works.
I believe source materials with plots that had been properly wrapped up at the end of the movie/book/comics can still inspire writers to create good fanfiction works. No matter how satisfied an author is at how they ended a work, there will always be fans who will think of better ways to end it. That thought inspires fanfiction works. That said, the quantity and quality of fanfiction works of a movie/book/comic may be affected by the level of popularity or exposure it has, and the demographics of the audience it caters to.
Before I share my thoughts further, I think it's important to define what we mean by "great" fanfiction because quality is subjective. For me, great fanfiction feels like it could be an installment to the source material. It usually features characters that are not OOC or if they happen to feature such characters, they manage to make it work using a good storyline. It doesn't have a cliche or overly predictable plot; and it has good narrative flow and construction.
Level of popularity - I've seen movies/books/comics with relatable, compelling, and inspiring characters and plots but have limited number of fanfiction works (and "great" fanfiction works). It's usually because it's not as widely popular as other movies/books/comics. This reduces the number of writers that it might be able to inspire to create fanfictions, in turn reducing the probability of finding quality works. The availability of a fandom that can demand fanfiction works also impacts the availability of published fanfiction. Knowing that there are people interested in sharing head canons, AUs, and alternate endings can boost a fanfiction writer's confidence to share their work.
Audience Demographics - Based on the fanfictions I've read, source materials that cater to a wide array of age brackets are likely to have more fanfiction works (and more "great" ones too). Writers who create my definition of "great" fanfiction are usually those who are fairly experienced in writing, confident and creative enough to think out-of-the-box storylines, and are capable of exhibiting good basic writing skills. There are young authors who can demonstrate this, but majority of the authors of "great" fanfiction I've seen are those who have more life and writing experience. They're not just good authors because of their age. They are good authors because they had honed their skills and imagination far longer than most aspiring young authors, who are just starting to create their first stories through fanfiction. Source materials that can cater to the interest of many experienced authors are more likely to have "great" fanfiction.
I'm not saying that a source material with a small fandom doesn't have "great" fanfiction. There are definitely less popular source materials with quality fanfiction out there. It's just that based on my experience in the field, the probability of finding "great" fanfiction is higher when the source material is popular enough to reach a wider audience especially a big enough, active, and supportive fandom that clamors for fanfiction works.