Originally, Obi Wan was supposed to escape the Death Star with the others. But there was a problem: What does he do the rest of the movie? Just watch from the sidelines? Lucas decided to kill him off, which would also make the escape from the DS more dramatic. He did a rewrite and told Guinness during filming in Tunisia. Guinness didn't like it, and when they got to England he told Lucas he would walk off the picture if the character was killed. They had a long lunch meeting, and Lucas finally persuaded Sir Alec that it was better for the movie and better for the character. Guinness later admitted that Lucas was right.
Ben Kenobi was a fairly late addition to the script. Originally there was an older general/warrior/bodyguard, sort of like in The Hidden Fortress, who was dropped. In a later draft there was a shabby but wise and mystical old Force-wizard that Luke stumbled across on Tatooine. I think it was in the next-to-final draft that Kenobi was created, combining the two. At first he was part machine, too, presumably because of battle wounds.
This is covered in The Making of Star Wars by Rinzler and Skywalking by Pollock.
--Justin