The primary reason that California (and Texas) both became parts of the United States is that a good many of the settlers there went specifically with teh intent of colonizing this land under the flag of the Republic as part of Manifest Destiny. While there were some adventurers that wanted to be in a free nation, there were many more American unionists.
In the case of Texas, many of the most famous founders of Texas were pro-union (like Sam Houston, and Stephen Austin), Texas voters chose union by a large majority, and the Congress of Texas, which was generally pro-independence, was brought around because of Texas' mounting debt. The US government paid off 10 million of Texas' debt when Texas was annexed.
The California republic was even more tenuous. A civil government was never really formed, and the militia that rose up in revolt against Mexico joined up with a US Army officer (John Fremont) within a month. So the revolt-havers specifically tied themselves to the US from the get get.
So this points to the reasons that independent California is unlikely: American settlers were generally pro-America and pro-Union and governing a large area with low population and tax base will get you in debt fast.
So the only reasonable explanation would be that California was peopled and funded by a foreign power BEFORE the influx of American settlers. In 1845 California had about 1500 Spanish and Mexican men, with 6500 women and children, and about 1300 American and 500 other European immigrants. Five years later, after the gold rush, about 100,000 more people had arrived. So a foreign power has to import at least 100,000 people before the gold rush to ensure that the state does not become inevitably American.
Here is a strategy to do this: Russian colonization.
In 1812, Fort Ross was established at Bodega Bay near San Francisco. In 1828, the Danubian Cossack host of 10-15000 men, under service to teh Sultan of Turkey, split, with one part going over to the Russians, and the other being massacred by the Turks. Instead, lets say the entire host went over to the Czar, who then banished/rewarded them with California. Many Cossacks died on a 3 year death march by land and sea across Siberia and the North Pacific, but in the end almost 20,000 men, women and children were established in the upper San Joaquin valley (Sacramento) where they expelled the Mexicans and repelled American settlers by force of the Cossack's legendary reputation for ferocity.
Eventually, gold is found, and a rush of Europeans of all sorts fills the land. As the Cossacks were progressively suppressed between that time and the Russian Revolution, more and more Cossacks made the arduous journey to California where their farming villages and fearsome riders covered the San Joaquin valley and extended to Napa and Solano, and eventually north to the Willamette, Snake and Columbia basins. European settlers fill port cities like San Francisco, Oakland, and Monterrey.
Still nominally part of Russia, formal independance doesn't come until after the Revolution in 1916. As losers flee the civil war, California (now known as Shelikhova) picks up a million more Russian imimgrants, establishing the new land as culturally Russian in perpetuity.