Why does Sachar include the line “He didn’t know he was Stanley’s great-great-grandfather” in this flashback?
It makes it clear that Stanley has never met or heard of his great-great-grandfather.
It explains to the reader that Elya was indeed Stanley’s great-great-grandfather.
It is a funny way of pointing out that Stanley and Elya are clearly not living at the same time.
It is a silly way of letting the reader know that Elya and Stanley are not really related to each other.