Quick Answer: Star Trek uniforms represent different occupational fields within Starfleet, the organization which represents most of the franchise’s central characters. Each field has its own color. These colors change between series and films, often the result of what showed up best on television at the time or suited the physical appearance of the actors playing the roles.
Everyone knows you don’t want to be wearing a red shirt during an away mission on Star Trek (1966 - 1969). You probably won’t make it back alive.
As it is, the death statistic can simply be attributed to the nature of the work those wearing red shirts perform. All Starfleet uniform colors are representative of a different branch of Starfleet. In the 1960s during The Original Series, red was the color worn by Starfleet security. If there is any occupation most likely to end in death when traveling to unknown regions of space, security is that job.
Starfleet uniforms have always been designed to best facilitate the duties of the wearer in his or her respective field. They also seek to maintain a dress code, establish hierarchy and chain of command, and remain comfortable in various environmental conditions.
Typically, uniforms are color-coded into three primary fields: Command (worn by ranking officers and those responsible for the administration of starships, starbases and space stations), Operations (composed of engineering, security, and support systems, responsible for technical innovation), and Sciences (the exploratory, medical, and mental health divisions).
The below charts, lifted from Memory Alpha’s entry on Starfleet Uniforms, shows how each division’s colors changed over time (and thus, throughout the many series and films).
While the colors varied between shows and movies, they were mostly consistent within their segments of the franchise. The colors not only made sense for an organization based on military practices, but it helped the viewer understand the roles of the people on-screen. This was particularly useful for minor or non-speaking characters; if a group of yellow-shirted people were running down a hallway in The Next Generation (1987 - 1994), viewers knew it was a security team without it being explicitly stated.
Some officers, like Deanna Troi (Marina Sirtis), wore different uniforms. Troi typically dressed in a more casual outfit. As a counselor, this was likely a means of establishing a more comforting and friendly atmosphere for her patients. Crewmembers like Worf (Michael Dorn) and Ro Laren (Michelle Forbes) were allowed to wear cultural additions to their standard Starfleet uniforms, which was typically permitted under authority of the Captain. There are also dress uniforms, worn on special occasions, which are variants of the standard issue uniforms.
Starfleet uniforms also signal a person’s rank. In The Original Series and Star Trek: The Motion Picture (1979), rank is indicated by sleeve stripes. Later TOS movies use pins on a shoulder strap and the left sleeve. In later television series beginning with The Next Generation, ranks are indicated by varying numbers of pips or bars on the wearer’s uniform collar.
No great reasons are ever given for the changes in coloration between films and series. In reality, it usually had to do with the costume design and production team’s wishes, working with what looked best on camera, and figuring out what colors best suited the actors. For instance, the gold originally worn by William Shatner and other command personnel on TOS was actually a shade of avocado green, but it often appeared gold on camera to the point where it was canonized as gold. The difference can be seen in juxtaposed shots with different lighting.
Kirk’s uniform on-camera and in real life
On TNG, Patrick Stewart and Jonathan Frakes looked better in red than gold. Brent Spiner, playing the washed-out android-human Data, mostly wears yellow as it was the color best suited to washing out the character’s flat-white skin tone. On the occasion where he wears a red uniform, the natural color of Spiner’s skin shows through the makeup more prominently. The bright colors of TOS were subdued for The Motion Picture, as Gene Roddenberry thought they would be too intense on the big screen, instead opting for a less intense palette.
As technology and coloration of television picture technology progressed, changes were made to the uniforms to show up best on-screen and provide the best contrast to one another.