Yes, a life insurance policy would pay out a death benefit if the insured person died as a result of cancer.
However, when you apply for life insurance there is a question on the application related to cancer - do you have or have you ever been diagnosed with any form of cancer?
If you lied on the application about not having cancer when you actually did, there may be an issue of misrepresentation of a material fact regarding your health, and the insurance company may be able to deny the payment of a claim, if you already had cancer and tried to hide it from the life insurance company when you applied for your life insurance policy.
So, always tell the truth when applying for a life insurance policy and you should be fine.
If you develop cancer after applying for and purchasing your life insurance it should be covered by your life insurance policy.
Life insurance policies usually cover death resulting from accidents and natural causes including health related issues like cancer.
Learn about life insurance for people with cancer.