Can someone tell me why just about all of the action in the Marvel Universe takes place almost exclusively in New York?
It doesn't. It takes place all over the world, and in fictional places like Madripoor and the Savage Land, and in realms like the Blue Area of the Moon, Asgard, the Shi'ar Empire, the Negative Zone, etc. The West Coast Avengers were based on... well, you can guess. The X-Men have been centered around the San Francisco Bay area in recent years. Their spinoff team Excalibur was based in Great Britain. Alpha Flight is in Canada. And so on.
Of the six Marvel Cinematic Universe films to date, New York City was the primary location only in
The Avengers, though it was one of several featured locations in
The Incredible Hulk and
Captain America, while much of
Iron Man 2 took place in nearby Flushing Meadows. The IM films are based mainly in Malibu, California, while
Thor took place in Nevada and Asgard.
In the DCU just about every member of the Justice League or the Titans spends their time in different cities. In Marvel, regardless of the team, they all seem to hang out in and around NYC.
Is there a reason for this?
The reason is because DC's titles started out as self-contained comics and only gradually began to establish interconnections, while the Marvel Universe that Stan Lee and his collaborators created in the '60s onward was treated almost from the start as a shared, interconnected world where characters from different books could cross over with one another, deal with common threats, be affected by developments in other books, etc. It was all part of making the MU feel like a larger, realer universe. Having many of the characters live in the same city facilitated such interaction, and New York is the largest, most cosmopolitan city in the US and one of the largest in the world. There's also the fact that Lee et al. wanted the MU to feel like it was happening in our world, with references to real places and events, rather than in fictional locales like Metropolis, Gotham, Central City, Star City, etc. NYC was the city they lived in and knew the best, so it was the one they could most convincingly portray.
(It also facilitated the frequent metatextual gag of having Marvel's authors, artists, and editors show up in the pages of their own books as spectators and chroniclers of the comics' events -- like when Lee & Kirby got bounced from Reed Richards and Sue Storm's wedding.)
Well, Metropolis and Gotham and so on all started out as thinly-disguised versions of Manhattan anyway.
Indeed, there's a very early Batman story that opens "In the calm of a New York night," and I think an early Superman issue also claimed to be in New York. It took a while to settle on Gotham and Metropolis as the respective settings.