Of course if Batman is also a superhero like Superman etc, he should save the earth from dangerous enemies.
So why is Batman restricted to Gotham city?
Science Fiction & Fantasy Stack Exchange is a question and answer site for science fiction and fantasy enthusiasts. It only takes a minute to sign up.Sign up to join this community
Every superhero began from somewhere. Batman had his origins in Gotham because it was a city that needed a symbol, a savior who selflessly acted right no matter what. Superman began from Metropolis that way, etc.
But when you look at DC heroes from the context of Justice League, you see that they leave and save the planet from bigger problems. Batman too has his part (a big one) in Justice League. He has traveled to multiple planets, timelines and universes.
So, it'd be wrong to say he operates only in Gotham.
I agree with the answers above, but I think there are some legitimate reasons why Batman is restricted to Gotham city.
First of all, for the majority of the more character-based analysis part of this answer I'll concentrate on Batman's latest incarnation in form of Nolan's Dark Knight trilogy as an example, so it may only be a partial answer in this regard. But I'd wager those movies' characterization of Batman is not entirely without comic precedent either.
In those movies it is made pretty clear that Bruce Wayne has a very strong bond with his city and a conviction for its well-being, one that carried over from his parents and was strengthened by their death and thus the certain death of their legacy of trying to improve Gotham. This is what drives him to make the city a better place by fighting crime and injustice there. And afterall the Nolan movies are very much about the fate of Gotham City in general and Bruce/Batman as its saviour. He just does not have much interest in saving the whole world, it's primarily his city that he wants to salvage from its demise.
And as a more general answer from someone only superficially informed about superheroes, there are many instances of superheroes concentrating their efforts on the home town only, which has not only the advantage of the hero's familiarity with the sourroundings, but also the readers' and writers' of having a common ground and environment for the hero to work in. This is not so different for Superman and his work in Metropolis, to employ your specific counter-example.
And for further out-of-universe analysis, in this regard the environment of the hero contributes as much to the atmosphere and themes as the stories themselves. Compare for example the bright and optimistic Man of Tomorrow to the brooding Dark Knight scaling the roofs of his gothic nightmare of a city. Especially for Batman Gotham and its out of control crime has always played a major role in setting the mood of his stories, from the corrpupt organized crime controlling the city, to the much more "small-scale" and psychologically characterized villains fitting to a more localized setting. Neither should Batman battle Darkseid on another planet, nor should Superman smash mobster goons in a back alley. ;-)