Lennie kills Curley's wife by shaking her so hard that her neck breaks -- remember, he is a big strong man. He does not kill her on purpose. He is only shaking her like that because he wants her to stop yelling.
She is yelling because he is holding on to her hair and won't let go. She asked him to stroke her hair but then he grabbed in a bit. When she started to complain, he panicked. He was afraid that George would not let him be part of the dream anymore if Curley's wife got mad at him.
So he's shaking her to try to protect his part in the dream. But he kills her and the dream too.
Lennie kills Curley’s wife because he ‘likes to pet soft things’.He is mourning the death of his puppy – also by his own hand – when Curley’s wife enters the barn. She tries to comfort him and allows him to stroke her hair which leads to him being overcome with he pleasure of the experience.
We have seen the inevitibility of the scenario with Lennie’s strength and Curley’s wife’s desire for affection and attention. He snaps her neck when attempting to silence her. She ‘flops like a fish’ in his arms: bitterly reminiscent of Curley’s actions earlier in the novel when Lennie crushes Curley's hand.
This answer is interpretive and contains a speculative analysis about Lennie and his actions.
There are many references to an incident in the town of Weed. George does not really know what happened because he was some distance away when the girl started screaming. Then he and Lennie had to run for their lives, so the only report he got was from Lennie. Lennie claims he only wanted to feel the fabric of the girl's dress, but later evidence suggests perhaps Lennie is developing an interest in sex and that his strong interest in petting soft little animals has been a budding interest in sex (which Lennie doesn't understand). When he begins petting Curley's wife's hair in the barn, perhaps he becomes sexually aroused, increasing his confusion and the violence of his reaction. It is very significant that George says the following words when he sees the dead girl lying in the hay in the barn:
"I should of knew," George said hopelessly. "I guess maybe way back in my head I did."
The reader, too, should know that Lennie is going to continue to be unable to control his reactions and desires. George can't be with him all the time. George wasn't with him when he frightened the girl in Weed, and George wasn't with him when he killed Curley's wife in the barn. (George doesn't really know what happened in the barn. It looks very much like an accidental killing in connection with an attempted rape--and that might not be far from the truth.) Lennie doesn't understand and can't control his sex drive, and his enormous physical strength makes him especially dangerous.
As he was stroking her hair she began to yell and he wanted her to be quiet as a result he covered her mouth and accidentally broke her neck ending up killing her.
Curley's wife was letting Lennie touch her curls but she didn't want him to mess it up so she kept telling him to stop grabbing it so hard. Lennie didn't know how to react to it so he didn't let go of her hair and he was afraid she would tell people so he covered her mouth but ended up breaking her neck, killing her.
He saw that Curley's wife noticed he killed the puppy and he wanted her to be quiet so he covered her mouth but accidentally ended up killing her.