Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.
There is no set distance you have to travel; it's all about increased likelihood. The further you go, and the more rings the wormhole has, the greater the chance that it will have something good (a lengendary or a shiny).
Wormholes with the two rings and auras are guaranteed to have a legendary. The chance of those wormholes appearing increases the further you travel.