In the mind of George Lucas, the ultimate sin for any Jedi to commit is the harboring of attachment, a rule cemented in the grand lexicon of Star Wars that all but guarantees the stories of most Jedi are fated to end in tragedy. The reason, as Lucas states, that attachment is the antithesis of the Jedi way is that it represents personal greed and the failure to remove oneself from the desire for more. In opposition to this, the Jedi are also taught to hold compassion and love for all things to uphold peace, creating a challenging dichotomy of emotions that proved impossible to keep separate for some Jedi.
At the core of this rule is the example of Anakin Skywalker, who flew in the face of the Jedi Code in favor of what he wanted to hold sacred to himself. From birth, Jedi are trained to disassociate themselves from the temptation of personal wants, but Anakin was already in his adolescence by the time he was taken for training, with love for his mother and his friends a part of growing up on Tatooine. Yoda was right to initially reject Anakin from joining the Jedi Order, as it was simply unreasonable to expect a young boy to stop caring for his mother when told to and foolish not to expect him to form attachments elsewhere.
George Lucas' Attachment Rule Means Jedi Romance Can't Work Lucas also uses Anakin as an example to show that, if one has something that they become attached to, the person becomes afraid of losing it. This fear of losing something that can't be controlled is exactly what Darth Maul used to lure Obi-Wan Kenobi into his trap on Mandalore in Star Wars: The Clone Wars, enacting his revenge by killing the Jedi's old love, Satine Kryze, right in front of him. However, following his tragic loss, Obi-Wan did not swear vengeance against Maul or mourn the death of Satine for longer than was necessary because, despite having them in the first place, he knew what it was to let go of his attachments.
In contrast, Anakin was willing to sacrifice everything to hold onto what he loved. His premonition of losing Padmé became such a terrible weight to bear that he turned to the pursuit of cheating death, which Lucas describes as the utmost form of greed. Ultimately, Anakin's obsession with maintaining his attachments was what brought them to slip through his fingers, decisively showing what becomes of Jedi who defy Lucas' rule.