A picture is worth a thousand words, so let's start like this:
[draws a big circle]
This is the fictional universe which you created. It should have solid fundamentals and internal consistency. You should be able to answer most sensible questions about it.
[draws a much smaller circle inside it]
Your story will only cover this bit.
By "you" I mean "me". You can write whatever, however the heck you like. But I've found this approach to work for me.
I can think of two major answers to this question. One is consistency.
In most cases it's desirable to avoid genuine contradictions wherever possible in a story. Direct contradictions (a character's eye colour changes from one chapter to the next) are relatively avoidable. What's harder to avoid are the contradictions which arise if the audience just asks "Why?" a few times.
When an audience is nicely engaged with a story, some of that audience, the curious ones, will start asking follow-up questions which lead outside of what is explicitly covered in the text. If the universe is well-constructed, they might be able to determine the answers for themselves, or at least get close, just by applying a bit of logic. In this way, while the strict scope of a story may end at what I will call a perimeter, it might be possible to analytically continue that universe somewhat beyond its perimeter. Or, if there's not enough information to nail down a singular answer, there may still be plenty of logical room in which several possible answers could live. This allows audiences to cultivate fan theories and head canon.
On the other hand, if a universe is poorly-constructed then a simple question may lead headlong into something which doesn't make any sense at all, and/or breaks the universe.
This is one reason why we worldbuild. We make it so that the boundaries of what we have worked out are some distance beyond the boundaries of what we show in the story. We try to anticipate those follow-up questions, we catch our own contradictions ahead of time, and we hammer them out. The result is, hopefully, something resilient and consistent; a universe which rewards exploration rather than punishing it.
Unfortunately, we can't just literally invent an entire universe. And, ultimately, all fiction is inconsistent with reality. Which means that sooner or later you are entitled to stop creating, and to start responding to follow-up questions with "I didn't think of that" or "I didn't work that part out". Additionally, the story/universe that you do create is still going to contain mistakes no matter what. Nevertheless, some worldbuilding effort, for the sake of consistency, should be considered part of the job of creating a story.
The other reason we worldbuild is that worldbuilding is too much fun. I don't think much elaboration is needed here. But this is the part where, and this is the reason that, it's possible to get carried away.
I'm not going to tell you not to have fun. But what I am going to tell you is:
It is true that some people love The Discworld Companion and A Few Notes On The Culture and the Lord Of The Rings appendices. These are fine and venerable works! They are not stories. And they're not crucial to any of those stories. They're completely ancillary.
Not everything you invented for your fictional universe will be revealed or should be revealed in the space of the story. In fact, I would say that as little as possible should. As a ratio, I think it would be somewhere around a fourth. The universe you created exists to support the story, not the other way around. Cut, cut, cut to the bone, the necessary skeleton. Remember all those amazing stories with zero worldbuilding, on account of being set in reality!
Don't get me wrong, keep it all. In your notes. Learn and re-learn it, lean heavily on your own reference works and your map and timeline and character sheets and whatever else you've constructed. Just don't put it in there, in the text, unless it serves a purpose.
If you do this, it may turn out that wide swathes of your universe go unexplored in your story. It may even be that much of your creation, practically speaking, cannot be explored in the form of a story at all. This may mean that many of your ideas never come to light.
Except actually it's not too bad! Ideas are cheap and you have a million of them. And it could be a blessing in disguise. Ideas which are hard to mine for storytelling potential might just not be worth the trouble of mining.
[now it's a video essay with really good editing]
The 1999 film The Matrix is a tremendous example of this concept in practice. The film shows a single, finite story in what is very clearly a much larger universe. Less than half of this universe is demonstrated in this original film. Other parts of the universe, not crucial to the story, are mentioned but not shown: ships other than the Nebuchadnezzar, the city of Zion. Obvious questions are raised, but they are left unanswered because they strictly don't need to be. Questions like: Who is the Oracle and what does she actually want? Why is there a One? Is the war now simply over?
As viewers, we can speculate about the answers. We could guess, for example, correctly, that the Oracle is a machine, although clearly different from the agents, whose objective is to end the war. As to the other questions, we don't have enough information, but we get the impression that the answers do exist, and that whatever they are, they are good and consistent. There is plenty of room for them.
But in any case, they are not required to support the story, which is relatively stripped-back. We have all we need. We don't need to see either the beginning or the conclusion of the machine war. Neo's narrative alone, from when he first wakes up to when he finally wakes up, is sufficient. It opens, it closes, done.
And despite all of this there's actually still a whole bunch of blunt worldbuilding/exposition in The Matrix. Think of any long conversation between Neo and Morpheus, particularly the first Construct scene. But, crucially, the exposition is compellingly executed. Much effort is expended in the first half of the movie to position what is technically exposition as dramatic revelation, as answers to long-asked questions. It works. This is one legitimate way of fusing worldbuilding with story!
But then came sequels, The Matrix Reloaded (2003) and The Matrix Revolutions (2003)... and you can probably already guess what I'm going to say.
Dissecting the sequels is a sizeable job. No single thing went wrong, and a lot of things went really right. But the major error, for the purposes of today's essay, was in the creators being more excited about exploring more of the Matrix universe than about telling the next story in that universe.
Nowhere is this clearer than in the Architect scene. This scene is the direct descendant of the Construct scene in the previous film. In this new scene, Neo meets the Architect of the Matrix. He is told that he, Neo, the One, exists to safely encapsulate the cascading mathematical errors introduced into the Matrix by the human need for choice (free will). Neo is told that he, humanity and the machines are trapped in a repeating karmic cycle of destruction and recreation, and that this is, in fact, the sixth Matrix, which is imminently going to be destroyed and replaced with the seventh. Neo then chooses to break that cycle, ending the war.
In my opinion, this basic concept is solid. This is the core of a single, solid Matrix sequel movie. Act one: Neo has questions. Why does he exist? Why is the war not over? Act two: Neo uncovers the fact that he is part of a repeating destructive cycle. Act three: he breaks it.
But there's so much other stuff going on in the movies that this solid core gets swamped, and eventually clamped into a brief terse infodump at roughly the sequels' midpoint, towards the end of Reloaded. Many of the facts delivered are contextless, coming out of nowhere, disconnected from anything seen in the preceding film. Unlike the first movie, the revelations are not devastating and epochal. The execution of this exposition is also uninteresting. Neo stands there and asks questions, the Architect sits there and gives answers. We don't get the effective, scene-shifting, point-underscoring CGI which Morpheus used for his presentations. And Neo's character at this phase in the story is too poised and cool to draw us in with a powerful emotional response, such as running away and throwing up.
And all this other stuff that's compressing this core story into such a tiny space is... not necessary. It's mildly diverting, but that's all it feels like, a diversion. The Merovingian and his evident backstory with Seraph and the Oracle, programs producing illicit offspring like Sati and sending them into the Matrix for safety, Niobe's parallel journey, Zion's physical layout and internal politics and religious structure, the Bane subplot, the Kid subplot...
Some of these angles are, at face value, potentially interesting. Regardless of their apparent potential, any of them could have been made interesting. All of them provide some kind of worthwhile additional angle on the core story. But none of them really factor in. And yet all of them take up screen time.
This is an important point: storytelling is expensive relative to exposition. To reveal a fact like "the Matrix is a virtual reality which pacifies humans while machines leech their energy" or "Neo is part of a repeating cycle of destroyed Matrices" is easy: it's a single line of dialogue. To reveal such a fact through organic storytelling, and to have its revelation have impact, takes screen time, and work. Most of a movie, in fact!
Ideas are cheap and plentiful. Have a million of them. But choose to execute few, well.
Build a big universe. Tell a small, complete story. (And actually complete it, you lazy bum.) And this is the disciplined part: If people are still interested? People are asking follow-up questions? They want to know what the other forty-nine constellations are, who that one ultra-ugly bit character was, how the ships work?
Ignore those questions and find the next story.