Can someone tell me why we need a head of state, whether hereditary or elected, given that the Prime Minister basically performs all the political functions of a head of state already?
Most (all?) democratic countries either have a head of state with executive power, as in the USA, or split the jobs of head of state (hereditary or elected) and de facto head of government (i.e of the executive), typically a prime minister accountable to the elected legislature. We fall into the second category.
The role of the head of state in the second category is to be symbolic representative of the nation, mostly for ceremonial purposes, but often with reserve powers, which may seldom or never be used, but which are available if for one reason or other the parliamentary system suffers a serious crisis. An example is when the King of Spain successfully called upon the armed forces to obey the elected government when a group of army officers attempted a coup in 1981.
In my view the advantages of a hereditary rather than an elected head of state are, first, that they are not seen as creatures of party politics, which arguably helps them to be more effective as symbols of national unity; and, secondly, because the hereditary principle is a powerful symbol of the continuity of our national institutions. (To be fair however I should however perhaps point out that in another thread Baboonery described this argument as 'nauseating claptrap'.) The Queen is directly descended from the Saxon kings who first formed the English national state, from William the Conqueror and from the old Scottish kings. I think that is nice; it gives me a warm glow.