The "Chaos Gods" are major parts of the background to
Warhammer 40k,
Games Workshop's science fiction wargame (and all its spin offs: the computer games,
Epic 40k,
Necromunda etc).
They also appear in on the
Warhammer Fantasy world (as shown in
Warhammer Fantasy Battle and it's spin offs), see
Warhammer Chaos Powers for descriptions of their role there.
The Chaos Gods dwell in the Warp...
"The warp is an alternate universe composed entirely of psychic energy generated by the thoughts, emotions and intellectual activity of living beings. The warp, to a much lesser extent, is also influenced by plants and animals. It is sometimes known as the Sea of Souls because of its spiritual reflection of life, but it is also known as the Realm of Chaos." (From Realm of Chaos: The Lost and the Damned.)
The negative thoughts of sentient creatures create disturbances and storms in the warp. Positive thoughts can act like oil on a stormy ocean, and get rid of warp storms. The 'Chaos Gods' are concentrations of the
negative thoughts, and are pretty powerful warp storms. The 'Chaos Gods' differ from most warp storms in that they are so big and powerful they become self-aware. However, peaceful areas can also become self-aware.
Khorne, Tzeentch, Slaanesh and Nurgle were all created by the bad vibes of intelligent creatures coming together. Mankind was fairly important in the
creation of Khorne, Tzeentch and Nurgle- their negative energies helped tip the balance that gave the mega-storms self-awareness. The creation of those 3 was fairly gradual.
"...the souls of men were troubled, obsessive, guilt ridden, or imperfect. These negative energies congregated together in the warp, drawn to each other by mutual attraction, until they formed troublesome spots of disharmony, rather like a tumour in an animal. These disharmonious forces eventually became the Chaos Powers..." (From Realm of Chaos: The Lost and the Damned.)
Of course Slaanesh was created rather faster and more violently (see The Fall of the Eldar), because the
Eldar are more psychic creatures so their emotions are more important in the warp. Especially when all their bad vibes are concentrated in quite a small area. The previous Eldar gods were all reflections of the aspects of the Eldar psyche, so most were self-aware areas of peace and calm rather than storms. Anyway, most of these calm patches were destroyed by the creation of the mega-storm Slaanesh. However some have advanced the theory that Khaine was a warp storm, which explains the myth cycles in which Khaine fights Isha, Vaul and the other 'good' gods.
Gork and Mork reflect the main vibes of the orkoid race- violence and cunning, respectively.
The Tau have a minimal warp presence, so don't have the vibes to create any gods.
I would write about the Necron "Gods" here, but I haven't yet read the Codex, so can't comment. It appears they may be something different though.
The Emperor, God of Humanity, was created by the mass suicide of the Shamans in 8000BC. Their collected souls mixed in a calm area of the warp, giving this calm area sentience. This created a new god, the Divine Emperor or Star Child. Note that whenever Mankind's darker instincts
take over (the Age of Strife and Age of Apostasy, for example) there are warp storms. This is because the bad vibes are creating them.