How did indirect development with planktotrophic larvae evolve?

How did indirect development with planktotrophic larvae evolve?