The Prime Directive has always been a staple of the Federation because they wanted to minimize influence they would have in underdeveloped civilizations.
Prime Directive Wikipedia
The non-interference directive seems to have originated with the Vulcans. In Star Trek: First Contact, it is stated that but for Zefram Cochrane's historic warp flight, a passing Vulcan ship would have deemed Earth unready for contact and ignored the planet, and in the Enterprise episode "Fight or Flight" T'Pol makes reference to a Vulcan policy of non-interference.
Apparently Vulcans were one of the first to implement a non interference policy as well. In the Star Trek First Contact film it was stated that Vulcan's would have ignored Earth for contact if it wasn't for Zefram Cochrane's warp flight. The directive wasn't even implemented in pre-Federation era and it was stated by Charles "Trip" Tucker III in the episode "Civilization" that the policy of non interference was actually a human policy but rather a Vulcan one.
Another thing to note is that the Prime Directive wasn't actually fully implemented until further into a bit further into the series. On the 13th episode of Star Trek: Enterprise called "Dear Doctor", Captain Archer states "Some day, my people are gonna come up with some sort of a doctrine, something that says what we can and can't do out here, should and shouldn't do. But until someone tells me that they've drafted that directive, I'm gonna have to remind myself every day that we didn't come out here to play God."
It was generally implemented as a general order around 2168.
The fundamental principles were an important part of Earth Starfleet procedures as early as 2152, but it did not go into effect as a General Order until sometime after 2168. (ENT: "The Communicator"; TOS: "A Piece of the Action")
It's stated that the Prime Directive stemmed from Captain Archer's interaction with two species in the episode I mentioned earlier called "Dear Doctor".
The "precursor" to the Prime Directive, though somewhat undefined, could be traced back to Captain Jonathan Archer's and Phlox's ethical dilemma faced when encountering two species, one with a terminal genetic illness and the other without. Archer commented that eventually, Starfleet would have to "come up with some sort of a doctrine" establishing what Humans should and should not do while exploring space and interacting with other lifeforms. They decided that interfering with the natural evolutionary course of these two species would go against the "directive" upon which they based their entire mission: to meet new species and attempt peaceful communications, not to "play God". (ENT: "Dear Doctor")
So it seems I actually have to elaborate more. The concept of The Prime Directive is a philosophical standpoint of not wanting to interfere in a planet's natural development of species and technology. Any influences that interaction with their technology or people would have can be far reaching and could possibly be disastrous. You can look to our own history to see evidence of what happens when even us humans encounter other humans who are more technologically advanced. The Spanish changed the lives of Native Americans and their culture tremendously with their arrival.
A major thing to note is that Starfleet is not the only one who follows something like The Prime Directive. Vulcans have their own version of it as well. Overall the reason that Starfleet personnel decided to follow it is because there is a general consensus that interfering with a planet's development is immoral. Hence why Captain Archer stated they shouldn't be "playing God".
You don't even have to look at just Star Trek to see why something like The Prime Directive is logical. Just recently there was an episode of The Orville, a show with similar tones but a bit more comedic, where one of the crew members ended up healing a child who had fallen and gotten hurt on an underdeveloped planet. That planet was actually was quantum locked in an orbit. It would orbit their home star, would slip into another universe and when it would slip back in days later the planet came back as though hundreds if not thousands of years have passed for it relatively. The Orville crew saw first hand what that interference caused, the people on the planet actually worshiped the image of the crew member as some sort of Deity, and created a religion around her. Even after attempting to go there personally and showing that she was just human and it was technology, one of the heads of the religion was murdered because he wanted to tell the rest of the world that their belief was a lie but the religious order did not want to give up their power and hold over the people. They had to send their robotic crew member to the planet to try to ease the tensions, though eventually the planet's evolution and technology stabilized with little assistance of the robot.