the rumor going around is that Joss decided to kill Cordelia off because Charisma left it so late to tell them about her real life pregnancy. storylines had to be hastily rewitten. i think, in the beginning, there was never supposed to be a Jasmine in S4, Cordy was supposed to be the major big bad. but, with Charisma being pregnant, she couldn't do any of the fight scenes the character needed to do. Joss got a little peeved at that, i think. abd anyway, after everything that happened to Cordy in S4, i don't think they had much left to do with her.
like TC said, Charisma said she would only return to the show if Joss didn't kill her off, but when she read the script and realized what a perfect ending for Cordy Joss had written, she changed her mind and did it.