Steinbeck was well educated and came from an affluent family. He had a burning ambition to write and he travelled through California working on ranches as George and Lennie did. Steinbeck was largely cataloguing the lifestyle of the people living the itinerant lifestyle that the ranchers had, whilst demonstrating the loneliness and isolation of such an existence. He was aware of the huge social and economic difficulties that these people faced, and also how their way of life was being eroded by the increase in mechanisation of farm work.
The novel is set in Salinas, California which is where Steinbeck was from. Using this setting was a regular feature in his writing and gave his novels a realistic feel.
Steinbeck was therefore inspired by his own experiences and through the stories of real people that he met. The characters in the novel are probably amalgamations of various people he encountered.