The other reason that CA is prosperous and red states are not: California is ethnically diverse. The #2 state in diversity is actually Texas, which helps explain why it is economically more successful than its neighbors.
Basically, red and purple states chased their gay populations to the west coast. While they were closing public schools to prevent them from having to integrate, California was building new ones. While red states make life difficult for Asians, places like NY and CA (and TX to some degree) welcome them. And so talent flows from the interior US to the coasts.
Human capital is the most important resource by far. Here's how California gets it: welcomes outsiders; minimizes discrimination; focuses on making a quality education available to as many people as possible. And guess what? That was the same recipe that propelled NC from backwater to above average in prosperity -- until the Republicans declared a war on education. We'll see how that goes. Meanwhile, most red states do the opposite and then they wonder why the smart people live and work elsewhere.