To borrow my answer from Book involving race-preserved characters, futuristic society of "stans" (or "norms")?:
Piers Anthony's Race Against Time as per my answers here and here.
John Smith is just a typical teenager growing up in a typical American town...Or is he?
He has a dog -- that can climb trees and understand very complex commands. He has parents -- who watch him constantly, taking notes when they think he's not looking. He has a girlfriend -- a girl he's never met, whom he has been told he must marry.
John knows that something is wrong, but until he crosses the boundary fence late one night, he doesn't realize just how much. For wherever he lives, it's definitely not America!
Humanity has homogenized to a general brown color. He's one of several children being bred to provide examples of separate races. He's expected to have children with the other white girl. One detail that stuck with me at the time is that they communicated via messages hidden in every third letter of their messages.
The bit with the spaceship didn't spark a memory with me when I first replied, but I've since found a copy and checked the ending, and indeed that is the case. The children escape on a spaceship and set a course for Earth, which results in them looping back and landing where they started.
Meilan nodded agreement. "Remember those alternate coordinates? We wondered how the system could
work, when each coordinate identified two places on the globe. Now we know that one is always
for Standard, the other for earth. The Standards renovated their own half but left the rest as a
perpetual monument to the mistakes of the past. So that man would never forget."
John was dismayed. "So we never really left the planet! We just spiraled around for two weeks! I
never thought to check the proximity of Standard once we were on our way."