Actually, they weren't 'illegals'. Many were given land grants, because the government of Mexico was encouraging settlement by just about everyone who could do anything productive:
Non- Spanish or Non- Mexican settlers like John Marsh, John Sutter, John Bidwell, and others were awarded large land grants.
Mexico wanted money coming in from their California territory, and they were more than willing to 'give away' land that they thought was pretty much useless to them, and they welcomed settlers with open arms.
Then in 1848 (prior to the 1849 discovery of gold and the ensuing rush of "Americans" to settle in California,) the Treaty of Guadalupe Hidalgo ceded California to the United States. So, in general, to call the early 'american' settlers of California is actually not correct.
...to call 'american' settlers of California ILLEGALS is actually not correct.
Just what was the Mexican-American War fought over?