The Horus Heresy
Once the emperor decided he wanted some friends, so he went into stem-cell research and made 20 buddies. So Chaos sent them every way hoping that at least half of them wouldn't suck.
Then a few years later the Emperor stops and thinks about where his 20 buddies went, and with his mutant powers found each and every one of them.
They followed him because they were dum and didnt know any better, but it took a grievous wound and a screwed up health-care system to make Horus see the light. THE GLORIOUS LIGHT OF CHAOS!
Well, then Horus takes the other 8 not-so-dumb Primarchs and fights the Emperor and his nine "pretty-marine legions", and then the Emperor used his H4x to kill the great Horus, but horus uses his l337 skills and injures the Emperor, so the emperor had to get hooked up to the portal-turned-super-life-force-chair. The emperor is kept alive by thousands of soul sacrifices.
Then the survivors of the horus heresy becomes our beloved Chaos Space Marines.