Spike wasn't good, per se. He was forced to act in a non-evil way because he had a chip in his head - the first thing he did when he thought the chip had stopped working was go on the hunt.
He was also trying to stay on Buffy's good side, because he wanted her. He also tried to rape her before he got his soul back - this is what forced him to think about the issue ("It's the chip! Steel and wires and silicon. It won't let me be a monster. And I can't be a man.") Somehow, he came to the conclusion that it would be better to get his soul back and have the shadow of a chance with Buffy than it would be to get the chip out and be able to be a monster again.
He was also trying to stay on Buffy's good side, because he wanted her. He also tried to rape her before he got his soul back - this is what forced him to think about the issue ("It's the chip! Steel and wires and silicon. It won't let me be a monster. And I can't be a man.") Somehow, he came to the conclusion that it would be better to get his soul back and have the shadow of a chance with Buffy than it would be to get the chip out and be able to be a monster again.