The original agreement between Marvel and Sony included the hero’s introductory appearance in Captain America: Civil War, as well as two solo Spider-Man movies — this summer’s Homecoming, and a sequel dated for 2019 — and an appearance in Avengers: Infinity War.
But after The Amazing Spider-Man 2 met horrible reviews and less-than-expected box office, Marvel struck a deal with Sony to allow them to MAKE a Spider-Man movie, but to let Sony distribute it.
Essentially, Spider-Man (recast with Tom Holland in the lead role) would appear in a story that exists in the MCU plotline.
They created three Spider-Man movies with Sam Raimi, and two with Marc Webb.