Throughout the novel, the tension surrounding George and Lennie's arrival to the ranch has been building. Curly, a hothead, is constantly comparing himself to the men on the ranch. He is possessive of his wife, and jealous of the other men; he often threatens to fight the other men to prove his worth. He is particularly suspicious of Lennie, who is considered simple minded by the other characters.
Curly's wife, on the other hand, is considered a flirt. She is unhappy with Curly, and hangs around the ranch to chat with the other men.
Lennie enjoys touching soft things, and accidentally kills a puppy in the barn one day after petting it too hard. Curly's wife meets him in the barn, and invites him to touch her soft hair. He pets her hair too hard, and when she resists, he panics and kills her.
This is the turning point in the novel. The storm finally breaks, and George can no longer protect his friend Lennie. Lennie's accidental violence towards living things has continued to grow; first, he kills a mouse that he was petting (at the beginning of the novel), then a puppy, then an adult woman. George realizes that he cannot protect Lennie from himself or others, and he has to make a difficult decision about the future.
Steinbeck chooses this moment to kill Curly's wife because up until then, there was a steady forward process that built over time. Lennie was becoming more dangerous and Curly was becoming more suspicious and violent. Finally, these two issues collide after a build-up of suspense and tension. The timing of this event forces George to make a very quick decision, before Curly or someone else can punish Lennie. The murder of Curly's wife happens so close to the end of the book because the resolution must be very quick.