When Disney bought Marvel, Sony held the Spider-Man movie rights. At that time, per the deal, Disney continued to receive a portion of Spider-Man box-office gross. Under 10% I believe.
Kevin Feige at Marvel later broached the subject with Sony, that it would be great to have Spider-Man become part of the Marvel Cinematic Universe, which didn't include Spider-Man (or X-Men, whose movie rights are held by Fox).
My understanding is, Disney gave up their shares in the Sony Spider-Man movies (unless their earnings pass a certain threshold). And why wouldn't they, it's a minimal sum as far as Disney is concerned.
Spider-Man could then appear in the Disney Marvel movies. In addition, Kevin Feige would produce the Spider-Man movie and other Marvel characters could cross over into Spider-Man.
A classic win-win scenario. Disney gets to include Marvel's most recognizable character in the Avengers. Sony gets their Spider-Man films to be a part of the immensely popular Marvel cinematic universe, and they get creative assistance from people who have proven very successful at making popular comic book movies.