First your premise is wrong. Starfleet has multiple missions and purposes, but it's the Enterprise specifically that:
Space: the final frontier. These are the voyages of the starship Enterprise. Its five-year mission: to explore strange new worlds
The Enterprise, both TOS and TNG, has a duty to explore strange new worlds. But that's only part of the mission.
to seek out new life and new civilizations, to boldly go where no man has gone before.
It is being sent to search for new sentient, sapient life. People it can trade and learn from, or from who it should prepare to defend from if they are a threat.
Second, strange has multiple meanings. While the first means different and weird, hard to understand, the second meaning is unknown, foreign, alien. This is in line with the Enterprise mission, seeking new people. It's a first contact mission.
Third, apparently in universe, the Enterprise mission statement comes from Cochrane, from the Enterprise Pilot.
On this site, a powerful engine will be built. An engine that will someday help us to travel a hundred times faster than we can today. Imagine it – thousands of inhabited planets at our fingertips... and we'll be able to explore those strange new worlds, and seek out new life and new civilizations. This engine will let us go boldly... where no man has gone before. emphasis mine
Out of universe, the intention was the same.
Finally, the mission is first contact and planetary charting. Strange planets, ones that don't have any sentient life or ruins detectable, are still noted, scanned, and mapped, for future research and follow up by dedicated long term teams. Case in point, Wrath of Khan, a research team returns to the sister planet that Khan was dumped on. Ceti Alpha VI was not expected to have any sentient life. Ceti Alpha V was "barely" Class M as it was too, no sentient life either. Both were cataloged by the Enterprise.
As a parting note, there were only a handful of classification for planets used on screen. Only some of these are considered to have life of any kind. Some classes are Gas Giants and the Demon worlds. Some are life less, atmosphere less rock planets or moons. Class L only had vegetable life. Class h is "generally uninhabitable". Class K needs Terra forming or pressure domes. The Enterprise can scan planets from space for life signs, or signs of civilization like ruins, buildings, man made structures. If a non Class M planet has no signs of life, they catalog it and move on.