20th Century Fox owns the movie rights to anything X-Men and Fantastic Four related. Sony has their hooks in Spider-Man. With the growing popularity of superhero movies, getting all of these characters to appear in the Marvel Cinematic Universe is a rights issue nightmare. Or would it? Typically, Marvel Studios waits for the film rights for characters to elapse. They did it with Ghost Rider, Blade, and Daredevil. With a hot property like Spider-Man and the Hulk (who can't be in a solo movie without Universal Studio's involvement), it takes a partnership. Sometimes things between studios become a little frosty. For years, Marvel and Fox have been had icy relations due to the latter owning the film rights to the X-Men and Fantastic Four franchise. Things are a little warmer now, but the idea of Wolverine appearing in an Avengers movie is about as likely as getting a glass of ice water in hell. Likewise, Fox releasing the reins on the X-Men so someone can finally make a good X-Men movie seems unlikely. Waiting is always the hardest part, and there is a very easy solution to have all the toys in the same sandbox:
What is Secret Wars?
For those of you who have been waiting out the Cold War in a fallout shelter for the past 30 years, Secret Wars was one of Marvel's first massive crossover events that featured every popular character in their roster of heroes. The Avengers, the X-Men, most of the Fantastic Four, Spider-Man and a plethora of their villains. It centered around a god-like being called the Beyonder who gathers the heroes and villains and have them fight it out on an alien world, offering the victors their greatest desires. It is one of the most well known and iconic Marvel events and if you have never read it you should be ashamed of yourself. Secret Wars proved so popular they have had five Secret Wars events over the years, the most recent being the summer of 2015.
Since Marvel has been adapting current story lines (at least in title) for the movies, then the most recent Secret Wars is iconic and been done recently enough that making a movie based on it should be a no-brainer.
What About Those Rights Issues?
You can take the plot points of either the original Secret Wars or the more current one and use that to explain away all the difficult questions. If your main villain is the Beyonder, it stands to reason that he doesn't have to grab heroes from a specific universe. He could gather members of the Avengers from the MCU, some of the X-Men and the Fantastic Four from Fox, and Spider-Man from Sony.
It would require all three studios working together to make the ultimate superhero crossover movie, but it would allow everyone to have their cake and eat it too.
There's a Precedence
With the upcoming release of Spider-Man: Homecoming we see that it is possible for Marvel Studios to work with another studio to make an epic superhero movie. It's not the first time they have done it either. Back when they made the Incredible Hulk, they had Universal Pictures on board with them.
If relationships between Marvel and Fox softening as it appears, it wouldn't be impossible for Marvel Studios to team up with Fox and Sony to make this epic. If all parties have a will it could be a profitable venture for all parties involved.
It Saves a Lot of Exposition
One thing the MCU has shown its that a shared universe movie franchise saves you a great deal of exposition. Thanks to the stand alone Avengers movies (Iron Man, Captain America, Thor, etc.) when you get around to watch The Avengers you didn't need everyone's back story.
If you were pulling characters from previously established cinematic universes it saves a lot of time on explaining who everyone is and chew up expensive screen time on exposition. Having a story that operates on a multiversal scale would also solve a lot of the hairy issues, like, how the X-Men can interact with the Avengers when the MCU has no mutants .
The way the original Secret Wars worked was that it could be read by long time fans and brand new readers so it was entertaining for everybody. The characters were iconic enough that we didn't need origin stories retold or their backstories explained. It was unnecessary!
How I Would Do It
In one universe, Doctor Doom discovers a powerful god-like being called the Beyonder and steals his power. Discovering that there is a multiverse where superpowered beings exist, the Beyonder then pits heroes and villains from the multiverse to learn about them. In one universe he gets the Fantastic Four. In another universe, he grabs Captain America, the Black Widow, and Iron Man, as well as Spider-Man and Luke Cage. From the same reality, he also pulls in Star-Lord, Gamora, Rocket, and Groot. From another, he grabs Wolverine, Deadpool, Cyclops, and Storm. Then put them up against villains like Doctor Doom, the Red Skull, Titanium Man, the Green Goblin and so on.
A concept like this couldn't be contained in one movie, that's why I also think it should be an epic trilogy. A Lord of the Rings of comic book movies. The first film we meet the heroes, and they fight each other. In the second, the heroes team up against the villains, particularly Galactus who threatens to consume Battleworld. In the third, Doctor Doom steals the power of the Beyonder and the heroes manage to defeat him and are sent back to their respective universes.
So you see, the idea of having the X-Men, Avengers, and Fantastic Four in the same movie in the near future is not impossible. All it needs is the will of the studios to work together to make an epic story like this become a reality.