John Steinbeck had experienced the kind of life he dramatizes in Of Mice and Men. He was concerned about the injustice and exploitation suffered by the itinerant agricultural workers he describes in his novella. He wrote the story because he hoped it would make Americans conscious of a situation they hardly knew existed. If public opinion could be sufficiently influenced, it should lead to the enactment of legislation that would give these oppressed working men some protection. At the same time, Steinbeck had an opportunity to write a play on the same subject which would be produced in New York. That intrigued him because New York was the cultural and intellectual capital of America, whereas California in his day was a fairly insignificant Western state. According to Wikipedia:
Of Mice and Men was Steinbeck's first attempt at writing in the form of novel-play termed a "play-novelette" by one critic. Structured in three acts of two chapters each, it is intended to be both a novella and a script for a play. He wanted to write a novel that could be played from its lines, or a play that could be read like a novel.
The play was produced in New York in 1937, the same year the book was published. The fact that Steinbeck was writing what he called "a playable novel" explains why most of the exposition is presented in the novella in the form of dialogue and also explains why the book is so short. Steinbeck obviously was thinking of how the story would "play" on a stage while he was writing the novella. He had to use indoor settings, because it would have been impossible in a stage play to show men and horses working in the California fields. However, when the story was adapted to two Hollywood feature films, the screenwriters automatically "opened up" the play by inserting big, panoramic outdoor scenes. The novella is not exactly a "script" for a play, as stated in the Wikipedia article; it is more like a "treatment." It was written in such a way that it could be quickly and easily turned into a conventional stage-play script. Time was of the essence.
What made Steinbeck a great writer was his humanity, his feeling for other people, and especially for the underprivileged. Most of his works, including his masterpiece The Grapes of Wrath, show that same powerful compassion.