"Obscene as cancer"is a subset of metaphor called simile. A metaphor is a comparison, and a simile is a particular form of comparison that uses the words "like" or "as."
"Obscene as cancer" is a simile that compares the bloody "froth-corrupted lungs" coming up into a soldier's mouth to cancer. Both are a painful ways to die, and both are obscene because nobody should ever have to suffer that way or witness another person do so.
Owen uses this metaphor to emphasis his larger point that modern warfare is not heroic or glorious. It is not two armies of strong , muscled, sword-wielding soldiers in helmets and breast plates meeting to fight gloriously to defend the homeland. Instead, it consists of men who are bent over, "coughing like hags," shoeless with bloody feet, and exhausted, dragging frail and weary through another day.
There is nothing heroic about being caught unawares by a gas attack, breathing in the gas, and being tossed into a wagon to writhe in agony while bloody bubbles ("froth") form at your lips. Rather than a manly fight to the finish, dying in modern warfare is more like ending up helpless in a cancer ward.
This is an anti-war poem, and Owen is at pains to ensure that his audience understands that the story which has been told for thousands of years—that it is "sweet and fitting" to fight and die for one's country—is, as he puts it, a "lie."