Julie Andrews gave an acclaimed performance in the role of Eliza Doolittle in the 1956 Broadway debut of "My Fair Lady". Her portrayal of Eliza in the stage production launched her career in theater, film and music. Directors of the film should have given her a chance to reprise the role rather than settling on Audrey Hepburn, who, in spite of being beautiful and well-known, could not sing well enough for the role.
Julie Andrews has a better voice than Audrey Hepburn so if casting a musical that requires range, Andrews would be the natural selection. My Fair Lady does not have a demanding score so they selected someone who could play a convincing, scrappy waif. That person is Audrey Hepburn. Andrews would have had to play Eliza Doolittle very differently than Audrey Hepburn. Andrews would have been an underdog who with training and education is the match for anyone, but she would not be accepted into society. The professor worked a miracle with Eliza, but it was more possible because the delicate boned Hepburn was more likely to become sought after. Hepburn is the waif turned socialite.
No, Julie Andrews played the role of Eliza Doolittle in the stage version of 'My Fair Lady', while Audrey Hepburn played the role in movies adding new distinction to the role. Audrey Hepburn is Rex Harrison's favorite leading lady because of this movie. Andrews went on to star in the Sound of Music, one of the most well-known musical films of all time. It is a Hollywood holiday classic enjoyed by everyone. If Hepburn had starred in the movie version of my Fair Lady, would she have suited the role for Sound of Music? Could we imagine Hepburn in the Sound of Music. It seems each actress was cast for the role that suits them best.
Julie Andrews already played the part in the Broadway version of the play, and she had been replaced and moved on to other projects. The live version and film version are different enough that it could have been very frustrating for her to play the role again. Instead, she pursued other very successful projects that advanced her career.