I think Marvel gains a lot more than you give them credit for. Spider-Man in the MCU is about more than just Feige wanting Spider-Man. I think Feige sees that Infinity War Pt1 and 2 have real shots at getting near (if not THE) top of the highest grossing movies of all times list, and he knows that a Spider-Man deal strengthens that shot.
Spider-Man is, by far, Marvel's most popular hero. Marvel Studios may not hold the rights to his films, but by integrating him into the MCU they strengthen the films they do hold rights to. Spider-Man appearing in, say, Civil War strengthens its box office potential. Spider-Man having a (possibly) prominent part in Infinity War pushes that film far ahead of what it would already hit. It's the same reason they dropped $40 million (or so) on Robert Downey, Jr. for Civil War. In a post-Winter Soldier era (grossed $714 million worldwide) a new Captain America filmand, specifically, one as wide-reaching as Civil Warhad a great shot at pulling in $800-$900m+ worldwide. Adding Robert Downey, Jr.'s Iron Man to that castby far Marvel's most popular movie propertystrengthens that by a huge amount. The film doesn't need RDJ to do well, but his addition multiplies how well it will do. It creates more excitement and increases ticket sales and overall interest. Suddenly your $800-$900m+ potential has grown to a $1b+ potential.
And it's not just about the few hundred million dollars more a Spider-Man brings to the Avengers table. It's about the news cycle that drums up, the merchandise it sells, the word of mouth it generates and the new people it brings into the theater (and whose interest now intersects with the Marvel movie brand).
You're right that Sony gains a lot more than Marvel does. Sony needs this right now. Marvel doesn't need Spider-Man. They'd get by just fine without it. This deal isn't about needing Spider-Man; it's about how Spider-Man's inclusion strengthens the Marvel Cinematic Universe brand, from box office potential to public perception.