This was a short story probably written well before 2010. I have an idea that it might be fairly well-known, but haven't managed to find it.
It started in the not-too-distant future. There was a permanent research base on the moon run by human staff with one experimental self-aware robot. I think the robot was called Sam.
The base crew was recalled to Earth at the outbreak of war, which surprised Sam as "he" had been told that war had been eradicated. The war eventually wiped out the human race and he came to believe that it had been done by hostile aliens, partly because of a well-written sci-fi book he mistook for fact. He used an automated factory on Earth to build an army of robots and led them on a mission to seek and destroy the aliens.
After centuries of travelling space and wiping out any moderately advanced civilisation they found, some robot researchers discovered that there had been no alien attack and the human race had destroyed itself. Sam concluded that his own race needed an overriding purpose to keep it from meeting the same fate, so he instructed the researchers to destroy the evidence and continued the impossible revenge quest.