Sounds like The Dream Millennium, although according to that synopsis they don't return to Earth at the end.
John Devlin, a 26-year-old2 medical doctor, is the captain of a sleeper ship built to colonize planets in other solar systems. The spacecraft's trajectory is such that it will make passes of eleven stars thought to have a good chance of supporting habitable planets, over the course of about a thousand years. Most of the starship's systems are automated, so Devlin does not have to do much maintenance, but he is required to look at potential planets for colonization and solve problems as they arise. Except for being awoken at long intervals to eat, exercise, and perform his duties as captain, Devlin spends all of his time in hibernation, during which he dreams the entire lives of people and other creatures that lived and died on Earth in the past.
.... Brother Howard wants to recruit Devlin and his girl friend, Patricia Morley, for the starship.
After their encounter with the aliens, Devlin makes several unsettling discoveries. One is that everyone on board the ship is having the same, or almost the same, dreams during hibernation. Another is that the dreams are slowly driving him insane, along with everyone else on the ship, driving one colonist to suicide. With Morley's help, he solves these problems, only to be presented with a new problem. The starship's electronic and electromechanical systems are failing as the starship ages. Only one more potentially habitable world can be reached before the life support systems begin to fail en masse, and Devlin and Morley discover to their horror that the world is inhabited by the same species of alien that attacked the ship during the flyby of one of the earlier star systems.
Faced with the alternative of dying with the starship as it travels forever as a derelict hulk, they decide to land on the world anyway and take their chances with the aliens. Once in orbit around the planet, preparing to land, Devlin and Morley find that the aliens fled their home world for the same reason they themselves fled Earth, to escape from the pollution and violence of their home world to found their own space colony, a possibility that neither Devlin nor Morley had thought of. These aliens are happy to coexist with humans, and welcome them to their new home.