Although we cannot be completely certain of why John Steinbeck wrote the novella, there are a few important clues.
First, he was born in 1902 in Salinas, California. This setting is the same setting as many of his novels, including Of Mice and Men. Moreover, he spent time working on farms when he was young. Certainly during these times, he saw the life of migrant workers. He also certainly became friends with them. In other words, their lives impacted his life. From this perspective, he had plenty of interaction and inspiration to write.
Second, Steinbeck was also conspicuously political. Therefore, it is clear that he was making a political point through Of Mice and Men about the hardships of the lives of the migrant workers. In Grapes of Wrath he does even more. In light of this, he probably wanted to share the story of these men to let others know what was taking place.