When NASA sends astronauts to space, they have to wear uncomfortable suits. Why aren't the humans in Star Wars spacecraft doing the same thing? What technology do they have on board that remove this need?
Real-world astronauts wear bulky space suits to protect themselves from extreme cold, radiation, and a lack of breathable atmosphere.
They only wear the suits if they are planning to enter such an environment (such as going outside their space station, or walking on the moon) or if they're about to do something dangerous where they are facing a higher risk of being exposed to such an environment (such as taking off or landing their spacecraft).
On board the International Space Station they do not wear the bulky space suits while going about their day-to-day activities.
Star Wars is similar. Most people on space ships do not wear protective suits, because the ship itself provides the air, warmth and protection they need.
Unlike our current real-world spacecraft, ships in Star Wars usually provide artificial gravity as well.
In the case of the X-Wing pilots, for a spacesuit to do any good it would have to survive the explosive destruction of your ship intact and then be able to keep you alive until you were rescued. The odds of this are probably pretty low. On the other hand a bulky pressure suit would probably reduce your piloting ability, making it more likely that you would be destroyed. So probably a net loss.
At one point in the Battle of Yavin one of the pilots shouts to another "Eject! Eject!", suggesting that X-Wings have some kind of ejector seat capability that can keep the pilot alive in space. Maybe the entire sealed cockpit is ejected, or perhaps a force field maintains enough atmospheric pressure, or perhaps some clever mechanism envelopes the pilot in a sealed bubble as part of the ejection sequence; we never find out.
If you look closely, you can actually see several characters in the Mos Eiesly cantina wearing space suits, not to mention BoShek, and Bossk from Empire Strikes back.