There are a number of factors which lead to her tragic and accidental demise.
First is the fact that Curley's wife was lonely. Even though she had married the son of a wealthy landowner, he was not much of a companion or a husband. One can see this from the manner in which she talks about him. Her references reflect a bitter disappointment and resentment.
"Sure I gotta husban'. You all seen him. Swell guy, ain't he? Spends all his time sayin' what he's gonna do to guys he don't like, and he don't like nobody. Think I'm gonna stay in that two-by-four house and listen how Curley's gonna lead with his left twice, and then bring in the ol' right cross?"
Since she was an attractive woman, it is clear that Curley married her for her looks and his own pleasure. He objectified her and treated her as an extension of himself. She was a mere possession and it obviously stroked his ego that such a vivacious woman could be his partner, since he had a massive chip on his shoulder and definitely lacked inner self assurance.
Curley was a pitiful character and could only express his power through violence, so he obviously abused her if she did not do as she was told by him. She therefore feared him and would, whenever she found herself in a compromising situation, escape when she had a notion that he was close by.
Because of her isolation, Curley's wife constantly sought companionship, someone to talk to. There is no suggestion that there were other women on the ranch and she was therefore left with the unfortunate situation that the only company she could actually find was that of the other men who were employed as ranch hands. She was desperate to share her memories and ideals with someone. She sought empathy and affection since Curley did not have the capacity to show her any.
Added to this, is also the fact that she was flirtatious. She needed to be appreciated and would therefore dress up for display, enticing the looks and admiration of the ranch hands. This was a particularly dangerous game that she was playing and George and the other men saw the risk in her flirting schemes. George, in particular, was acutely aware of the fact that her actions could land someone in jail - his comments to Lennie in fact, foreshadowed the tragic denouement of the novel.
"Don't you even take a look at that bitch. I don't care what she says and what she does. I seen 'em poison before, but I never seen no piece of jail bait worse than her".
"Well, you keep away from her, cause she's a rattrap if I ever seen one".
All of the above aspects contributed to Curley's wife's fatal encounter with Lennie in the barn. A further consideration is Lennie's mental incapacity and his childish desire to touch and feel soft things that added to this most unfortunate outcome. In her desire to share her thoughts with someone, she started speaking to Lennie, later allowing him to fondle her soft hair. Lennie could not control himself and held a bit harder. One other factor is that Lennie had no understanding of the power and strength he had in his massive hands and obviously, he was too rough. She, on the other hand, became afraid and started shouting when Lennie became too rough.
Furthermore, instrumental in this tragedy is the truly sad fact that in his fear of being, once again, the cause of trouble which George had warned him about, Lennie attempted to stop Curley's wife from screaming and clamped her mouth shut. This obviously drove her into a panic and Lennie tried to subdue her, but tragically, broke her neck, killing her instantly, just like he had killed the puppy and the mouse which he had literally fondled to death.
Lennie was in a panic. His face was contorted. She screamed then,and Lennie's other hand closed over her mouth and nose. "Please don't," he begged. "Oh! Please don't do that. George'll be mad." She struggled violently under his hands. Her feet battered on the hay and she writhed to be free; and from under Lennie's hand came a muffled screaming. Lennie began to cry with fright. "Oh! Please don't do none of that," he begged. "George gonna say I done a bad thing. He ain't gonna let me tend no rabbits." He moved his hand a little and her hoarse cry came out. Then Lennie grew angry. "Now don't," he said. "I don't want you to yell. You gonna get me in trouble jus' like George says you will. Now don't you do that." And she continued to struggle, and her eyes were wild with terror. He shook her then, and he was angry with her. "Don't you go yellin'," he said, and he shook her; and her body flopped like a fish. And then she was still, for Lennie had broken her neck.