The classic account of this is Alan Cameron, Circus Factions: Blues and Greens at Rome and Byzantium (Oxford, 1976) - some more recent work has been done on ancient sports but I don’t think anything has surpassed Cameron’s work on the chariot racing factions.
Basically...we don’t really know! Historians have speculated that maybe the different colours came from different neighbourhoods of Constantinople, or maybe they were related to the different doctrinal interpretation of Christ's humanity/divinity. Cameron rejected those explanations and argued that the sources simply never tell us why the Blues and Greens were more popular.
“Why and how Reds and Whites were weaker than their rivals is altogether obscure, but it is a fact which must be accepted...the sudden and violent notoriety that came to the Blues and Greens in the fifth century has nothing to do with the ascendancy the same Blues and Greens exercised over Reds and Whites. Their greater popularity and power is a phenomenon as old as the Empire itself, of social significance only in so far as it may be inevitable that a highly competitive sort will divide a compact population into two rather than four primary loyalties” (Cameron, 72-73)
It's not even certain that the Reds and Whites were older, as is commonly believed. The 2nd-century Christian author Tertullian is the only one who says that the Reds and Whites dated back to the time of Romulus, but his account is surely full of legend. No one was actually sure when the different colours were founded, or who founded them or why. They probably all dated back to the republican period, or even the monarchy, if not literally as far back as Romulus. (This is contrasted with the history of gladiatorial contests, which did have a specific, well-known origin.)
The Blues and Greens were always politically more active and relevant, going back to the early Roman Empire:
“Whenever we hear of the factional reference of an emperor, from as early as the Julio-Claudians it is always either for the Blues (Vitellus, Caracalla) or the Greens (Gaius, Nero, Domitian, Verus, Commodus, Elagabalus)...Reds and Whites are scarcely named in the literary sources. It is otherwise with the non-literary sources, the inscriptions and curse tablets, where there is frequent reference to the Reds and Whites…Each of the four factors had its charioteers, grooms, doctors, and the like, but the fans tended to divide into just two parties: Blues and Greens.” (54-56)
The emperors did not always divide into Blues and Greens; Anastasius was a fan of the Reds, for example.
By the 6th century, clearly the Blues and Greens were the biggest and wealthiest factions and they were responsible for the rioting in 565 (the Nika riots), and representatives of the Blues and Greens were even incorporated into coronations and other imperial ceremonies. But all four factions are attested for as long as the chariot races lasted in Constantinople, which was at least up to the 12th century.