Texas I'd have to imagine is a much easier state to operate a large corporation than California.
Also Musk pointed out that Tesla wasn't leaving California. They are actually expanding some operations. Mostly Tesla was just relocating the HQ to Texas.