I’m no theologian, and I don’t play one on TV, either. But I do have some thoughts on the matter.
If you assume that G-d is perfect, as most monotheistic religions do, then it follows that He did not make any mistakes when He created the universe and the laws of nature that govern it. However, when He created mankind, He gave us free will (and, thus, the ability to make choices).
We’ve all made at least one wrong choice at some point or another in our lifetime. And our choices never affect ourselves alone – we are all interconnected via our relationships with one another and with the different elements of nature. As John Donne wrote,
No man is an island,
Entire of itself.
Each is a piece of the continent,
A part of the main.
If a clod be washed away by the sea,
Europe is the less.
As well as if a promontory were.
As well as if a manor of thine own
Or of thine friend’s were.
Each man’s death diminishes me,
For I am involved in mankind.
Therefore, send not to know
For whom the bell tolls,
It tolls for thee.
And sometimes, even when we’re trying to make the right choice, we end up with negative consequences. I’m reminded, in particular, of the TV show “Person of Interest”, in which the two main characters attempt to save various people who are in danger of losing their lives. However, sometimes they end up saving the life of one person who will go on to take the lives of many other people. We are incapable of making choices that do not affect others.
In terms of cancer, we’ve chosen to take advantage of the way G-d’s laws of nature work in order to create products and substances that make life easier or more convenient, or that allow society to prosper. And while none of these inventions may have been intended to cause harm, many have. The creation of plastics that may contain carcinogenic compounds, the use of asbestos in construction, the reliance upon nuclear power plants that may harm the surrounding population in the event of an accidental meltdown – these are all inventions that were meant to advance society but that have also ended up harming it to some extent.
So, G-d is perfect, and so are His laws of nature, but we aren’t. And, as a result, sometimes we misuse His laws of nature, even if we don’t mean to. But if G-d intervened in the working of His laws of nature through miracles every time they were misused, there would be no point in having laws of nature in the first place, or in having free will.
That’s why bad things, like cancer, happen to good people. G-d allows us to make our own decisions, and since our decisions affect everyone around us, other people’s poor or uninformed choices can start a chain reaction that negatively affects good people.