I am not finding a good resource on how parliament evolved from what seems like a group of ministers appointed by the Kind of England (before the Unions), to how they are voted for today. When the Prime Minister went from being the King's appointed representative in Parliament to being totally (in practical terms) out of the monarchs control, and the choice of the Parliament itself. Although they do report directly to the Monarch the status of Parliament.
Magna Carta did reduce the King's power a bit, but just to give more power to the nobles, not really democratic. So I don't really count that.
The thing is that there weren't many really seismic moments of change, but a gradual process as some offices and institutions gained power and others lost it according to the political currents of the time. Most of the really old offices that used to hold significant power, like the Lord Chamberlain, still exist, albeit with only ceremonial roles.
Originally, the king had the central power and was advised by a group of ministers appointed by him (the Privy Council), but the king's power was counterbalanced by the demands of barons and other local interests. Magna Carta stipulated that the king could not raise taxes without the consent of his subjects, and in following years this was formalised into the system of "Parliament" - loosely based on that used by Simon de Montford's rebel barons in 1265. The first such Parliament was the Model Parliament convened by Edward I in 1295. These were ad-hoc affairs, convened by the king when he needed them and dismissed when their job was don.
The early parliaments were unicameral, being composed of both the powerful lords and clergy, and two representatives elected from each major city or borough. Initially, the representatives were not always summoned - if the king just wanted advice, he might only bother to summon the Lords. While they were originally intended as a device to authorise royal taxation, they became a useful venue for the elected representatives to air local grievances and make petitions to the monarch, because unlike the lords they had few other opportunities to do so. As the number of these petitions grew, the task of dealing with them was delegated to various royal ministers in order not to overwhelm the king's time.
Parliament steadily grew in power whenever there was a weak king, or one desperately short of cash. During the Hundred Years War, it split into the two Houses that we know today (though the Lords was the most powerful house), and it was firmly established that the king could not raise taxes without the consent of both Houses. The House of Commons, led by the Speaker for the House, began to impeach ministers it disapproved of, though often without success.
During the Tudor era, Parliament gradually assumed responsibility for much of the regular legislation within the kingdom, though still under the monarch's loose direction and subject to royal veto. The power of the clergy was enormously diminished after the Dissolution of the Monasteries, reducing the Lords Spiritual to the handful of bishops still present today (previously, many powerful abbots had seats in the Lords). When the Stuarts took power they clashed heavily with Parliament, as they were used to the Scottish system which as I understand it conferred much more power upon the monarch. Charles I tried to reduce Parliament back to a rubber stamp summoned only when necessary, but this precipitated the English Civil War, which after Parliament's victory massively increased its power. Under the Commonwealth, the Lords was abolished and government was vested in ministers who sat in the Commons.
The return of the monarchy reversed some of these reforms (particularly in the return of the House of Lords) but the supremacy of Parliament was now firmly established, a situation later enshrined in law under the Bill of Rights (1689) and Act of Settlement (1701). The monarchy still held final authority, but this was lost under the early Hanoverian kings (George I and George II), who spoke little English and were unfamiliar with English law and customs. George I therefore was completely reliant on his ministers to do the job of governing, in particular the powerful and ambitious Robert Walpole, who was nicknamed the "Prime Minister" due to his control of the government. Officially his role was as First Lord of the Treasury and Chancellor of the Exchequer, and the job of Prime Minister was not formally recognised in statute until 1917.
The role of prime minister continued after Walpole's resignation. They were always appointed by the monarch (they still are today) but it was quickly apparent that there was no point in the monarch trying to appoint a PM whose supporters did not have a majority in the Commons, because he could not get anything done, and so the PM was always the leader of the party that won a majority in the elections. Of course, the elections then were not very democratic, being often based on very outdated borders. Some tiny villages (Old Sarum, Dunwich) still had theirmedieval right to send their two MPs to parliament, while relatively new cities like Manchester had little representation. Ballots were not secret and usually controlled by local powerbrokers. These were dealt with over the course of the nineteenth century in a series of Great Reform Acts.
So, to answer your question more directly: the Prime Minister was never really a representative of the monarch, and at the same time he always has been and still is. But right from the start, the PM derived his power from his control of parliament (in order to pass laws) rather than the monarch's approval. Royal power over the PM has only disappeared completely under Elizabeth II. In 1916 George V mediated the downfall of Asquith and his replacement by Lloyd George (with the goal of preventing any instability during WWI), and during WWII Churchill and George VI held regular meetings to discuss the course of the war.