The mystery of how the darkest galaxies in the Universe came to exist may have been solved by scientists.