That sounds like the Grebulon ship from Douglas Adams' Mostly Harmless ("Part five of the increasingly inaccurately named Hitchikers trilogy.")
The Grebulon ship is damaged by something (presumably an asteroid,) leaving part of it open to space. Due to the damage, the computer controlling the ship is unable to detect the damage - it infers that the ship is open to space because the robots it sent to replace the memory units in that area all disappear.
Unfortunately, the spare memory unit was lost with the robots who went to install it. The memory unit contained a copy of the ship's programming and copies of the memories of all the Grebulons on board. The Grebulons were in some kind of suspended animation - preserved because the trip was planned to take a very long time.
Based on the fragmentary remains of the original (damaged) memory unit, the computer determines that they were sent to set up an observation post and observe something. The structure of the fragmentary records implies that the Grebulons are a scout force for an invasion force, but the computer doesn't recognize this.
The computer lands on the planet Rupert in our solar system and wakes the crew to have them set up an observation post and observe the activities of humans on the Earth.