Hi, this question seems to come up a lot, mainly from people who do not have access to reliable info about the production history of DS.
Grayson got the gig to play Julia by a lucky accident, and turned the rather uninteresting role as written into something very special. DC met Sam at Grayson's parties and liked him. When a new writer was needed, DC knew that Sam did not then have a job commitment and offered him the role. This was mid to late October 1967, by which time Grayson and Julia had become fixtures on DS. Sam's first episode was the one where Barnabas is trying to drive Julia insane (like he didn't do that just by being Barn, lol) and Julia had this line about their being a thin line between love and hate that the script gave her to deliver to Barnabas. I thought it was a neat twist on their relationship.
If DC had given Sam the go-ahead to have Julia killed off, I don't think it would have meant Grayson's exit from the series. I'm quite sure she would have been brought back, in a role as different from Julia as possible. Grayson sometimes had issues with Julia's being, as she colorfully phrased it, "such a straight-ass."
Best wishes,
Gothick