Star Trek: The Original Series and its subsequent sequel series, Star Trek: The Next Generation, did not share a lot of things. The technology was different, the cast was different, the capabilities were different, and even how they handled problems was different. To an extent. Yet, one of the biggest things that changed from show to show was the color of the uniforms.
The original series was to feature green for command, red for engineering and security, and blue for science. The green was washed out, however, and so many people thought that gold (or mustard yellow) was the color for command. That became the trend for the rest of the original series, that gold, red, and blue represented the command, security/engineering, and science of each ship.
So when The Next Generation came around, that became the accepted order of things. Except, it didn't. As the story goes, Patrick Stewart didn't think he looked commanding in the gold and didn't think he'd be able to pull it off. Transversely, producers were concerned that the red would make Data look weird, as his skin was gold and the color contrast wasn't great.
So according to legend, the producers opted to flip the colors, turning red into command and gold into engineering and security. Fans seemed to embrace this more than expected, as Den of Geek pointed out, the Star Trek films changed up the uniforms so that everyone had the same attire, just with different frills and badges. People got used to seeing William Shatner's James T. Kirk in red, so when The Next Generation dropped.
Personally, the color change worked. The colors seem to fit better with the current lineup and it's one of the main reasons that through the years both in the franchise and in reality, the colors have never changed again. Even on Star Trek: Discovery, which is set around 1,000 years after the events of the original series, command still wears red, security and engineering wear gold and science wear blue.
Sometimes it's good to fix things. Also, it didn't hurt that it was Gene Roddenberry okay'ed the change.