Fred Saberhagen's Berserker series is a space opera in which robotic machines intend to destroy all life.
"Berserker" stories — many of the books are short story collections — describe humans' fight with the Berserkers, ancient asteroid-sized killing machines designed to destroy all living things in the universe. The Berserkers are a doomsday weapon from an ancient interstellar war. Humans are the only sentient species that is aggressive enough to put up a fight.
Warning: Wikipedia contains spoilers.
The first story, "Without a Thought" (1963), was basically a puzzle story where the protagonist faced a problem of simulating intelligence to fool an enemy trying to determine whether there was any conscious being present on a ship.
Saberhagen came up with the Berserker as the rationale for the story on the spur of the moment, but the basic concept was so fruitful, with so many possible ramifications, that he has used it as the basis of many of his stories. A common theme in the stories is of how the apparent weaknesses and inconsistencies of living beings are actually the strengths that enable the machines' eventual defeat.
In later stories there are "goodlife" — i.e., sophont traitors or collaborators — who cooperate with the berserker machines to stay alive, at least for a while.
Note: "Berserker" is a registered trademark of Fred Saberhagen (presumably only in the field of science fiction?). Berserker books
Some of the collections have duplicate stories.