So how could I have presented this problem and solution in a way that would not have suffered this fate?
I don't believe that you can on Stack Overflow. Let me give it a few tries, keeping in mind that the question must be judged by itself, whether or not you self-answered.
How do I use D3 to illustrate all the spaces that a chess knight can move to in n moves?
That would be seen as a "Give me teh codez plz" question and would have been closed as too broad. And it really is too broad. It's basically asking people to write a fairly large program in the answers.
Here is my attempt at making a D3 illustration of the moves a chess knight can make [code follows] How can I improve this?
This might be okay on Code Review. On SO, this has no specific problem or error, so either too broad, unclear, or off-topic > Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.
Really, the underlying problem is that you don't have an underlying problem. You're just trying to show off a program you wrote. Stack Overflow just isn't the place for that. Put it on Github, Gitlab, SourceForge, or something and post a link on Hacker News. Or maybe post a link in chat. But don't ask a question unless you have a question.
Back to your statement
Where are interesting questions?
There are many sides to that particular debate. Since you're looking at it in terms of interesting questions that aren't allowed (rather than in terms of a deluge of bad questions flooding all the interesting questions away), I'll respond to it that way.
"Interesting" is not a good judge of things that are suitable for Stack Overflow. There are many things that are interesting but off topic.
Stack Overflow used to have a lot of these questions, but we've moved on. If you want to talk about that, I advise looking into the reasons:
Keep in mind that many of the choices that were made back then are the reason that Stack Overflow is so heavily used by programmers today. If Stack Overflow had kept things open because they were popular, it would likely have slid into the depths of useless fun sites and some other, stricter programming site would have sprung up and all the programmers would have gone to it.
Because at the end of in the middle of the day, programmers need answers, not entertainment. Entertainment gets an unfair amount of attention and makes it harder for people to find answers to real questions.
That isn't to say that there isn't anything interesting on Stack Overflow. Just all the interesting stuff has to be on topic. There are these classics:
Those aren't kept open because they're interesting or popular. Those are all good questions. If you asked one of those today, it would be closed as a duplicate and it hadn't been asked before, it would be well-accepted.