Raimi warmed up to the idea.
Sam Raimi brought the first big-screen depiction of Spider-Man to life, and his influence on the superhero genre is immeasurable. Even the latest Spider-Man movie, Homecoming, paid respect to the original film with similar hero/villain interactions. The moment that Michael Keaton realizes Peter is Spider-Man is just as menacing and memorable as the moment Willem Dafoe did the same in the original. Raimi wasn't always a fan of placing Stan Lee in the films as a cameo reports The Hollywood Reporter, but he warmed up to the idea later.
"I got the job for Spider-Man in 1999. And [Marvel head] Avi Arad said, 'I want you to put Stan in the movie,'" revealed Raimi. "And I was like, 'No. I know Stan, and he can't act.' And Avi was, 'I want him in the movie. We did it for X-Men, we're doing it here.' Now imagine you're a minor director in England doing Macbeth and you're told, 'Put the writer in the play.' It sounds absurd. 'Fine, you want Shakespeare in the play, I'll put Shakespeare in the play.' Now it's one of my favorite parts in the movie."
Stan's appearances in both Captain Marvel and Avengers 4 have already been filmed. Beyond that, I believe Disney may have a vault of cameos lined up for the future.