When examined piece by piece, the Star Wars franchise is an exercise in cultural hodgepodge. George Lucas and his collaborators borrowed a lot of stuff from a lot of different sources, both historical and fictional. One of the more visually distinct examples is the way the Jedi's robes and capes stand out against otherwise futuristic environments.
The original Star Wars trilogy takes place in a galaxy with very few surviving Jedi. Obi-Wan Kenobi and Yoda are the only examples before Luke picks up the lightsaber. Obi-Wan and Yoda happen to be decked out in the same outfit, but their traditional garb isn't properly canonized until fans saw everyone wearing it in The Phantom Menace.
Why do Jedi wear robes in Star Wars?
From a canonical perspective, the robes are more of a preference than a command. Jedi do not have a dress code. From the time a youngling becomes a Padawan, they're free to wear whatever they want. Plenty of Jedi don't opt for the classic look. Aayla Secura, for example, shows up to battle in a sports bra and yoga pants to allow for complete freedom of movement. The robes are a traditional choice, and though they're the most common look for Jedi, they're totally optional.
The tunic and cloak get-up offers a few benefits in the Jedi business. They're warm, comfortable table, and flexible, their flowy motion can be distracting in combat, and their earthen tone represents the Jedi's preference for simplicity. The hood allows Jedi to disguise themselves and blend into a variety of public situations. Many Jedi throw armor on over their robes, maintaining the traditional look while also preparing for the worst. Many in-universe figures note the similarities between Jedi robes and the traditional garb of monks. This comparison is obviously on purpose. Outside the narrative, the Jedi wardrobe has several clear points of inspiration.
Akira Kurosawa inspired a lot of Star Wars
When listing the many elements of history and fiction that inspired George Lucas, the works of beloved filmmaker Akira Kurosawa always make the list. Kurosawa has a long and respected filmography, but most of his best-remembered features are period dramas set in the time of the samurai. His 1954 classic Seven Samurai clearly had a lot of impact on George Lucas. Lucas famously offered Toshiro Mifune the role of Obi-Wan Kenobi, likening it to an aging samurai. Kurosawa's influence on the franchise persists to this day, often in more straightforward homage. Seven Samurai's heroes appeared on the scene in traditional hakama, usually without any form of armor. This led Lucas to dress his knights more like samurai, ditching the shining armor for flowing robes. Darth Vader's suit was also designed to evoke the samurai look.
George Lucas didn't want Star Wars to look like other sci-fi
One of the key elements of George Lucas's work with designers, both before and during the production of the original 1977 Star Wars is his desire to avoid comparison to other science fiction. He was heavily inspired by the Flash Gordon serials that were big when he was young, but by the 70s, sci-fi had a bad reputation. Most sci-fi outings of the time were either niche art-house projects like 2001 or Lucas's own THX 1138 or cheap genre schlock. Lucas wanted his new sci-fi universe to look real, lived-in, and above all else, used. This was interpreted by the designers in several ways. Most notably, the bad guys all look and act like Nazis and the good guys all look like cowboys. Obi-Wan donned a cross between traditional samurai garb and the look of Buddhist monks and that look stuck.
Interestingly, the Jedi robes are one of the least frequently mentioned elements of Star Wars design. There are pages of notes about Darth Vader's design and multiple iterations of tiny creatures that would eventually become Yoda, but the crew seems to have gotten the Jedi done in one. The Jedi are warrior monks, representatives of an ancient faith, and mystics that stand out against the crowd. The robes and capes would be the logical choice for a character like that. The franchise has gradually moved away from the robes in its more recent iterations, fully embracing the lack of a dress code to mix some things up.
Jedi robes are an interesting piece of costume design that simultaneously evokes samurai, Buddhist monks, and old-school wizards. The look is distinct. It's familiar, while still managing to feel like something new. Jedi are free to wear anything, but the earth-tone robes, long wool cloak, and big brown boots are the go-to look as far as the fans are concerned. The look has aged extremely well, even 45 years after its debut. The warrior monk aesthetic has gone on to be influential across genres, but everyone still knows that as the Jedi's signature style.