I think the hardest thing for Buffy to forgive Spike for was not, actually, the attempted rape, but his failure to save her from herself. To quote her in “Life Serial: “You were gonna help me! You, you were gonna beat heads and, and, and fix my life! But you're completely lame!”
In “After Life”, Spike promised Buffy he would save her (“Every night I save you.”). In “Once More With Feeling”, he sang her back from death. And Buffy turned to him, to help her, to fix her life. And he failed her. And it wasn’t his fault—he didn’t have a soul, is all. But in a weird way, I think what Buffy blames Spike for the most is not trying to rape her (which is, at least, a very straightforward thing where she can say, “He was wrong, I was right”) but not stopping her from using him, or from beating him up in that alley. “But at the same time, I-I let him completely take me over,” Buffy tells Holden, in “Conversations With Dead People”. She trusted him, and he failed her. But it’s not his fault: “[T]he joke is... he loved me. I mean, in his own sick, soulless way, he really did care for me.”
Buffy says, in CWDP, “I didn't want to be loved...I wanted to be punished. I wanted to hurt like I thought I deserved.” But I don’t think that’s the whole story. When she’s struggling with financial problems in “Flooded”, she asks Spike if he knows anything about the subject. In “Life Serial”, she’s furious with him for failing to help her, for failing to fix her life. She starts the affair in “Once More With Feeling”, after he saves her life, and sings to her that she has to go on living.
When she thinks she’s killed Katrina in “Dead Things”, he tells her, “Trust me,” he says, and she does. She leaves the scene of the crime, and lets him handle it. Later, she will be enraged at him for how he handled it. But it’s not his fault.
In the confrontation in the alley, Spike says, “Why don't you explain it?” He doesn’t know it, but that is absolutely the wrong thing to say. It proves that he doesn’t know. He can’t help her. He can’t be her moral compass. He can’t fix her life. She can’t explain—how would he be able to understand? And how do you explain morality? Even Faith, who had soul, was told over and over and over that living without morality was wrong. And yet, she had to literally become Buffy, and experience first-hand what it meant to be a moral person, before she had any desire to change her ways. Spike, too, had to experience it firsthand. Realize that he had hurt the woman he loved, and the only thing keeping him from doing it again was her (“Because I stopped you. Something I should have done a long time ago.”).
And back in that alley, Spike takes the beating from Buffy (“Come on, that's it, put it on me. Put it all on me.”). He doesn’t hit back. He tells her, after, that hitting him was an act of love. He proves, once and for all, that he can’t provide her with the limits she needs (not that she should ever have expected that from another person in the first place).
I don’t think Buffy went to Spike just out of hatred and punishment, although I’m sure that was part of it (and I assume, in the alley scene, she was expecting him to hit her back). She went to Spike because she wanted to be loved, cared for, and understood. Spike not only knows, when he first sees in “After Life”, how she got the wounds on her hands (“Clawed her way out of a coffin, that's how.”), but he did it himself.
“We'll take care of you,” he tells her, as she comes down the stairs, and he does. He tries.