Assume you’re life-lusted and are willing to abandon every moral you have just to live. Paying for cancer treatment is also worth prison time to you.
Also assume you’ve exhausted all ethical fundraising options, i.e. GoFundMe, loans, etc. and that insurance won’t cover treatment for whatever reason.
Immigration is complicated, and you are thinking only of "legal" immigration. It is extremely common for people to ignore those laws. And a job is not always required, no.
You (generic you) don't need to really emigrate to a country to receive treatment, you could go with a tourist visa or visa free and get treated, then go back to the shitty country without universal healthcare where you live.
In my home country everyone has access to healthcare because it's a human right, so by law it doesn't matter what your immigration status is, you will get care. This includes cancer treatment, for free.