Curley's wife is lonely. Throughout the book she is looking for someone to talk to, or someone to pay her any attention. It's clear that she's not getting this attention from her husband, so when she walks into the barn and sees Lennie talking to himself, she realizes she's found someone like herself.
“I get lonely,” she said. “You can talk to people, but I can’t talk to nobody but Curley. Else he gets mad. How’d you like not to talk to anybody?”
Lennie tries to avoid talking to her (after all George explicitly told him to stay away from her) but she keeps trying to talk to him. When she starts telling her story, it's obvious that Lenny is not listening to her. He keeps talking about the dead puppy and the farm, but she keeps on talking without giving him a chance to interject.
She went on with her story quickly, before she could be interrupted.
Finally his discussion and her story merges when he's talking about touching soft things. She's excited that they finally have something in common to talk about. She jumps at the chance to carry on an actual conversation with someone else.
Curley’s wife laughed at him. “You’re nuts,” she said. “But you’re a kinda nice fella. Jus’ like a big baby. But a person can see kinda what you mean. When I’m doin’ my hair sometimes I jus’ set an’ stroke it ‘cause it’s so soft.” To show how she did it, she ran her fingers over the top of her head. “Some people got kinda coarse hair,” she said complacently. “Take Curley. His hair is jus’ like wire. But mine is soft and fine. ‘Course I brush it a lot. That makes it fine. Here—feel right here.” She took Lennie’s hand and put it on her head. “Feel right aroun’ there an’ see how soft it is.”
Unfortunately, this conversation leads to her death as Lennie pets her soft hair. Sensing something is wrong, she begins to scream, and worrying he'll get in trouble Lennie accidentally breaks her neck.