Robin Williams' Genie in Aladdin is one of the most iconic Disney creations of all time and the deal he made when he signed on makes the performance even better. Disney's Aladdin began life as a pitch from Howard Ashman, a lyricist whose work includes The Little Mermaid and Beauty and the Beast, in 1988. Directors Ron Clements and John Musker (Moana, Treasure Planet) then joined the project shortly before Ashman's death in 1991. One of the characters that Clements and Musker created in their draft of the screenplay was the Genie, whom they wrote with Robin Williams in mind.
https://screenrant.com/aladdin-robin-williams-genie-disney-agreement-great-reason/