The struggle between love and duty is one of Anakin Skywalker's major conflicts in the Prequel Trilogy. Newer Star Wars fans may not realize, however, that Attack of the Clones was the first time the idea of Jedi celibacy ever came up. In the Expanded Universe, Jedi before and after the Prequel Trilogy had no problem with falling in love, getting married, and having family ties outside of the Jedi Order.
With the Expanded Universe in mind, the question becomes less "why can't Jedi marry?" and more "why did the Jedi taboo against marriage develop, and why did it later disappear?"
Early Jedi Practices and the Expanded Universe
The Jedi Order was founded in 25,783 BBY, and their philosophies -- such as the distinction between the light side and dark side of the Force -- developed over the next few centuries. They served as the guardians of the Republic since its foundation. It wasn't until around 4,000 BBY, however, that the Jedi began to forbid marriage and attachment.
Practically speaking, this is due to the structure of the Expanded Universe. Before the Prequels came out, EU writers had to avoid the Prequel Era so as to avoid contradictions with later material. For the most part, the EU covered events in between the Original Trilogy movies and after Return of the Jedi. In order to explore new time periods and characters, works like Knights of the Old Republic were set 4,000 to 5,000 years before A New Hope and featured Jedi marrying with no problem. When the prohibition of marriage was revealed in Episode II, it only made sense in the EU if it started after 4,000 BBY.
In-universe, the new rule prohibiting marriage is justified by changes in the structure of the Jedi Council and Jedi Order. Before 4,000 BBY, the Jedi Order was made up of loosely affiliated local groups. After the Great Sith War, they became a unified organization under the Jedi High Council, which began to reinterpret the Jedi Code. Among the new regulations were the prohibition of marriage and the idea that Jedi must begin their training as very young children.
Dangers of Attachment
The reorganized Jedi Order focused on eliminating attachment because of how it can lead to the dark side of the Force. The problem is not so much falling in love, but the fear of losing the object of one's affection. This plays out in Revenge of the Sith, in which Anakin turns to the dark side to prevent Padmé's death. The loss of a loved one can also cause a Jedi to turn to the dark side in anger -- as happens to Anakin ater his mother's death.
The Jedi of the Prequel Era are not only forbidden to have romantic attachments; they are forbidden to have familial ones. Force-sensitive children are taken from their families at a young age and brought up in the Jedi Temple, without much or any connection with their biological relatives. They are loyal and devoted to the Jedi Order because they have no other family.
Is Attachment Inherently Bad?
The idea of attachment being dangerous is not new in the Prequels. It goes all the way back to The Empire Strikes Back, when Yoda warns Luke not to rush into danger just to save his friends. It happens again in Return of the Jedi, when Darth Vader manipulates Luke into attacking by threatening to harm Leia.
And yet, Luke trained as an older student and got married -- and allows such things in the New Jedi Order -- without the problems the Jedi worry about in the Prequels. The Jedi Order is simply smaller and more disjointed, much like the Jedi before 4,000 BBY.
It seems that prohibiting marriage and other attachment is not a matter of necessity, but a matter if practicality. The Jedi of the Prequel Trilogy prohibit attachment not because it always leads to the dark side, but to encourage devotion to the Order. Perhaps it also avoids creating Jedi dynasties that might divide the order. Since Luke started his New Jedi Order with older Force-sensitives who had already developed attachments, there was no practical way to forbid them; he simply worked with what he had.
From this point of view, one might conclude that Anakin's fall was not the fault of his attachment, but the fault of the Jedi Order. If the Jedi of the Prequels were more familiar with the needs of older trainees, and if they taught their students to deal with attachment wisely rather than forbidding it outright, Anakin may have been able to let Padmé go without fear.