The star of Suicide Squad, I, Tonya and Mary Queen of Scots will also produce the movie through her production company, LuckyChap Entertainment.
In a statement, Robbie said playing with the doll promoted "confidence, curiosity and communication".
"I'm so honoured to take on this role that I believe will have a tremendously positive impact on children," the Australian actress continued.
Robbie, 28, said she could not have imagine "better partners" than Warner Bros and Barbie creator Mattel.
The film, which has yet to have a title, a director or a release date, marks the first collaboration between the two US companies.
"Margot is the ideal producer and actress to bring Barbie to life on screen in a fresh and relevant way for today's audiences." said Toby Emmerich of Warner Bros.
Comedian Amy Schumer had previously been cast to play the doll, only to drop out of the project in 2017.
"I'm bummed, but look forward to seeing Barbie on the big screen," the star of Trainwreck said at the time.
It was rumoured last January that Anne Hathaway was in talks to take over the role.
In October, it was reported that the film, previously a Sony production, would use a "revised" script by Ocean's 8 writer Olivia Milch.
The first Barbie doll, made by Mattel, was introduced to the world at the New York Toy Fair in 1959.
The character went on to appear in a string of TV shows and animated films, among them the Toy Story movies.
Scandinavian band Aqua famously had a hit in 1997 with their single Barbie Girl, which contained the lyrics: "Life in plastic, it's fantastic."