I would argue that the function of philosophy is twofold. First and foremost, it provides a kind of meta-analysis of the various academic disciplines—science and history, for example—examining their underlying presuppositions and their claims to knowledge, and seeing how they make good on those claims. In that sense, philosophy is a kind of foundational discipline which provides us with an epistemological (relating to the theory of knowledge) perspective on all other forms of human intellectual endeavor.
The second main function of philosophy is the clarification of words and concepts. This approach has been particularly prevalent in Anglo-American philosophy, where successive generations of philosophers have sought to clear up what they see as unnecessary confusion arising from the failure of traditional philosophical language to get a grip on reality.
Eminent philosophers such as Wittgenstein have argued that all traditional problems in philosophy are ultimately problems of language that arise from a misunderstanding of how language actually operates. If we understood that the truth-value of language comes from how it is used on a daily basis in our engagement with the world around us, rather than through the formation of abstract concepts, then we'd find that many of the so-called perennial problems of philosophy would disappear.