thereby hangs a tale
Used to indicate that something requires a long story or explanation to fully understand.
And thereby hangs a tale. François Rabelais
And so from hour to hour we ripe and ripe, And then from hour to hour we rot and rot And thereby hangs a tale. William Shakespeare