Time goes "by". "By" is the preposition you use to describe a passing object. For example, "did you see the car that just drove by?"
So "by and by" creates an image of something passing without specifying exactly what it is that is passing. The implication is that it is one's life, or time itself, that is passing.