Churning of milky ocean was an uphill task. It was not possible to perform it without the help of Demons (Asurs). Hence Gods reached for an agreement with Demons to accomplish this task and it was decided that all perks coming out from the milky ocean would be shared equally including the nectar of immortality. During churning of milky ocean when the pot (Kumbh) of nectar came out, a fight broke out between the Gods and the Demons to get it completely without sharing it with the other.
According to Hindu scriptures the fight between the Gods and the Demons continued for twelve years. During the fight the pot of nectar was shifted from place to place to keep it safe from demons. During this time few drops of nectar were spilled at twelve different places. Out of those twelve locations four were on the Earth and remaining eight were on the heaven.
Due to spilling of nectar drops, four places on the Earth, Allahabad, Nasik, Haridwar and Ujjain became sacrosanct. Hence Kumbh Mela is held only at these four locations.
As the Sun, Moon and Brihaspati played a major role in safe-guarding the pot of nectar from demons, the Kumbha Maha Parva is organized only when these three planets form a special Yoga by positioning themselves into specific Rashi.