All sorts of different species inhabit the Star Wars universe. How is it that their biological function is compatible with the same atmospheric gases, and that the gravity is the same on all the planets, and the sun is just the right difference from the planet to sustain life?
There's never been any indications that ALL the planets in the Star Wars universe have breathable environments, survivable levels of gravity, etc. We see a lot of those kinds of planets because, well, otherwise our characters wouldn't be on those planets. But we do see gas giants like Yavin and Endor from space.
There's also plenty of indication that there are planets with radically different environments that still support life. The Jedi Plo Koon, for example, wears a rebreather mask since he doesn't breathe oxygen. While I'm not sure it's ever stated in a canon source, his home planet of Dorin is rich in helium.
As for why there are so many habitable planets, it's not that unrealistic. Star Wars takes place in an entire galaxy. The Milky Way has billions of stars and even more planets. Chances are, there are as many potentially habitable planets in our galaxy.
In my opinion not all planets in the galaxy far far away are habitable, it's just that we are mostly shown planets that are. There wouldn't be much of a story if everyone on a planet were dead.
Kel Dor's species have to wear masks since they breathe something other than oxygen (helium and Dorin gas).
Gungans are an amphibious species so they are also quite different from humans
Many planets wouldn't be able to evolve intelligent life. For example, Hoth was an ice planet and home to primitive tauntauns and wampas.
Another example is Mustafar, which is a volcanic planet.
As for why all species are pretty much the same humanoids with the same biological functions, it wouldn't make a good story if everyone had to wear space suits all the time when they were on other planets. Regarding gravity, it would be weird if Jedi came to some planet with G15 and couldn't move an inch, wouldn't it?
But that's just my take on the thing :D
It's now part of the Legends universe and non-canon, but the video game Knights of the Old Republic establishes that
an ancient race called the Rakata used powerful technology to terraform many planets to suit their desires.
This is also the explanation for why many of the planets shown in the films are "single-climate" planets (e.g. desert planet, snow planet, forest planet), something that would be incredibly unlikely in real life.
You can read about the Rakata here: http://starwars.wikia.com/wiki/Rakata, but I highly recommend actually playing the game.
Aside from that, the films and other media cover life-sustaining planets because completely uninhabitable planets are not very interesting settings and Hollywood hates putting masks on actors.
They don't all contain human-breathable atmosphere. The Kel Dor breathe helium and Dorin gas, and are poisoned by oxygen-rich environments (plus carbon dioxide and nitrogen in Legends canon). They wear a filter mask to compensate.
In Legends canon, there are a couple of different atmospheric types. Type I is human-breathable. Type II is potentially toxic, but can be managed without aid in the short term. Type III require a breath mask, and Type IV requires a full environment suit.
Not all of the planets are habitable, as many have said before me, however the story only takes place on these planets with breathable oxygen and gravity similar to (or the same as) Earth's.
This is great question over which i was wondering also. At first let me say that most answers here fail to recognize the real problem pointed out here in part because the answer is clumsily formulated. The better formulation which comes to my mind is:
Why it is that planets which support some life and we get to see them in star wars movies and other media are of such nature that almost all are habitable by human. In other words, how it is that most of aliens we get to see demand same environment as human
At first note that rare exception like Plo-koon does not count to counterpoint the question, as we don't ask for all planets and aliens but most. Even Plo-koon share same need of pressure, heat, gravity and other things. He just cant breathe but don't have problems with other parameters.
I came to some answers, which are itself dubious but make some sense:
Humans may be one of the oldest intelligent species in galaxy and so they were able to colonize more planets than any other species. (But that does not mean more than other species combined.)
Humans may belong to most probable intelligent life-form to evolve, in other words, earth like conditions may be most probable environment to support life and many of the lifeforms could evolve from the similar planets. (Yet this does not mean most of all, although earth like conditions could be the most probable condition it does not mean it would be more than the others combined) (Also there are species like space-whales, so pretty improbable one)
It may be that most of habitable planet are product of terraforming from some even older species like Rakatan empire or Sentinels.
It is possible that humans or other specie which need similar environment just force most of other planets to terraform and than force native to adapt by genetic engineering. Although there is some tendency to human supremacy, it seems improbable. And if the humans were so abusive to change environment of strangers planets, why would they care to modify them and don't let them die? And how would they change gravity?
Humans or some older species with need of same environment just destroyed most of planets with lifeforms incompatible environment.
It is the will of force to unite all species together
It is humans who are modified to survive most conditions. That is improbable because we see most of other species to interact together on Coruscant.
There is big number of planetary life with environment non-compatible to human yet we don't get to see those planets because we follow human heroes. Well it seems possible but if there is big number of such planets, than they should have some influence in galactic politics and warfare so our heroes would have to go there. Also we don't see much of the species with technical life support in senate.
It may be that those species are ignored by galactic government. But how it can be, that they are so weak that they do not force the government to count with them. If we say there is more of them, than the ruling one, it is improbable.
All of the above combined.
So those are my ideas.
Please forgive my English and spelling errors.