This is almost definitely Clarke's The City and the Stars. Quoting from the plot summary on Wikipedia:
The City and the Stars takes place (at least) two and a half billion years from the present—ten rotations of the Galaxy since the apparition of the human species in the novel (one rotation of the Solar System around the galactic center (a galactic year) is equivalent to 220–250 million years)—in the city of Diaspar. By this time, the Earth is so old that the oceans have gone and humanity has all but left. As far as the people of Diaspar know, theirs is the only city remaining on the planet. The city of Diaspar is completely enclosed. Nobody has entered or left the city for as long as anybody can remember, and everybody in Diaspar has an instinctive insular conservatism. The story behind this fear of venturing outside the city tells of a race of ruthless invaders which beat humanity back from the stars to Earth, and then made a deal that humanity may live—if they never leave the planet.
In Diaspar, the entire city is run by the Central Computer. Not only is the city repaired by machines, but the people themselves are created by the machines as well. The computer creates bodies for the people of Diaspar to live in and stores their minds in its memory at the end of their lives. At any time, only a small number of these people are actually living in Diaspar; the rest are retained in the computer's memory banks.
All the people currently living in Diaspar have had past "lives" within Diaspar except one person—Alvin, the main character of this story. He is one of only a very small number of "Uniques", different from everybody else in Diaspar, not only because he has no past lives to remember, but because instead of fearing the outside, he feels compelled to leave. Alvin has just come to the age where he is considered grown up, and is putting all his energies to trying to find a way out. Eventually, a character named Khedron the Jester helps Alvin use the central computer to find a way out of the city of Diaspar. This involves the discovery that in the remote past, Diaspar was linked to other cities by an underground transport system. This system still exists, although its terminal is covered over and sealed, with only a secret entrance left.