^^What @FireMadeFlesh said.
Stories often start as a problem. Let’s say you have a problem in your life. (Who doesn’t?) And let’s say you feel your viewpoint isn’t quite represented by your cohort or the masses. So, you write an explanation from your point of view in an invented story form (which you can control) in order to put your point across.
Here’s an example: Hemingway’s short story, Hills Like White Elephants, It’s about an American couple traveling by rail through Spain in the early 1930’s. They are waiting for a train in a nearly deserted station in a small village. The village is on an arid plain with hills in the distance. The couple is chatting intermittently like two people in a fairly matured relationship do. You get the feeling that they have been together for awhile. Soon, the reader realizes that there is a problem with these two, and it’s evidently a big one and they have avoided addressing it until now. They don’t exactly say what it is, but the conversation is obviously pregnant with something that could be a deal breaker.
I’m not going to blow this story for you because it is one of Hemingway’s best. The subject they dance around, the elephant in the room so to speak, was treated the exact same way in real life in Hemingway’s time as it is in the story. It’s still a sensitive subject but it was unspeakable in Hemingway’s day, even among couples in matured relationships.
The story presents a valid, complicated and sympathetic view of an unpopular opinion without ever actually mentioning the subject. I suspect that Hemingway, being at times both a practical and selfish man, shared the view of the husband in this story and was using his writing to put across his side of the argument.
Hemingway and others didn’t and don’t just pull stories out of their butts. I imagine that Hem, being popular with the ladies of Paris as a young, successful writer in the 20’s and 30’s, might have been in this situation, possibly with a mistress. He had traveled Spain for the trout fishing and bull fighting circuit. He loved it, even the sparse, arid Spanish plain on the rail route between Paris and Madrid (think The Good, the Bad and the Ugly or other 1960’s Sergio Leon/Clint Eastwood films). So, in this case, in order to drive home the emptiness one feels when a relationship may be about to end, he used that sparse plain.
You, see. Very little inventing went into this. Hemingway had had enough romantic relationships to reasonably determine what the 1930’s woman’s reaction would be. He had had marital problems, mostly due to his own infidelities, and knew exactly what a devastating silence was. He had an opinion that was not shared by the general public and wished to put forward that opinion in a proper environment in a sympathetic way. So, he created the story from what he knew.
Same with Crane’s Red Badge of Courage. Crane had seen hand-to-hand combat, he had seen young men enter battle for the first time and turn from boys imagining the heroic romanticism of victory into cowering jelly soiling themselves in the trenches when the violence starts. Crane used that experience as a hook to seduce readers, then put across his unpopular view of war.
In other words, both these famous writers had a problem which was an upopular view that they felt, if they could only present that view in the proper circumstance, they might broaden the conversation concerning the problem. They didn’t just dream it all up. It was a combination of wishing to be heard and personal experience.
Dickens wrote of the social injustice he saw in 19th century British society and built stories around that problem with his childhood experiences. Victor Hugo did the same. They merely applied the framework of personal experience to a problem they saw, and started the badly needed social consciousness and progressivism that survives to this day. The situations described in their stories were very real, they weren’t fantasies. They were very real.
You don’t have to go to Spain, have extra-marital affairs, or subject yourself to frontline combat, be a rags-to-riches orphan, or live in the sewers of 1840’s Paris to do any of this. The experiences one has in high school and college, their first entry into the job market, the social injustices they see around them, are all fodder for good stories.