The answer has its roots in the history of the Jewish calendar. Originally, there was no fixed calendar. Each month anew, the Sanhedrin (Rabbinic Supreme Court) in Jerusalem would determine whether the previous month had been 29 or 30 days long -- depending on when the new moon of the following month was first sighted -- and would accordingly sanctify the new month.
There was no way to determine in advance the exact day of a coming festival, because every festival falls on a particular day in a month, and there was no way to determine in advance when the month would begin.
(The way that the Sanhedrin determined the new month is fascinating in itself, Click here to find out more about it.)
Originally, the starting date of every new month was broadcast from Jerusalem to distant Jewish outposts via huge bonfires which would be lit on designated mountaintops. Lookouts stationed on other mountaintops would see that a fire had been lit and would light their own fire. This chain of communication led all the way to Babylon, and even very distant communities knew when the new month began. If there was a festival that month, they now knew when to celebrate it.
But a problem arose. The Sadducees, a sect of Jews who denied rabbinic authority and were constantly at odds with the Sanhedrin, started lighting fires on the wrong days in order to manipulate the calendar.1
To prevent this confusion, the fire-on-mountaintop method of communication was discontinued, and instead messengers were dispatched to Babylon and all other far-flung Jewish settlements.
Since news travels a lot slower that way, distant communities would not know when Rosh Chodesh (the "Head of the Month") had been declared in time to celebrate the festival on the proper day.
It was therefore decreed that outside of the Land of Israel people would celebrate two days for each festival – the day it would be if the previous month had been a 29 day month, and the day it would be if the previous month had been a 30 day month.
Even though nowadays we have a fixed calendar,2 this tradition continues. Jews outside the Land of Israel celebrate each biblical festival for two days.
There are two exceptions to this rule:
1) Yom Kippur is still only celebrated for one day because fasting for two days is untenable.
2) Rosh Hashanah is celebrated for two days even in the Land of Israel. Rosh Hashanah is celebrated the first day of the month of Tishrei. Until Rosh Chodesh Tishrei was declared, communities both inside and outside of the Land of Israel were subject to the same uncertainty as to when to celebrate Rosh Hashanah. So everyone everywhere celebrated it for two days.
Nechama Posner,
Chabad.org.