Under what circumstances can a Prime Minister be replaced?

The Prime Minister's role in the UK is deeply intertwined with the political party system and the will of the people. Unlike some countries where the head of state directly appoints the head of government, in the UK, the Prime Minister is the leader of the party that can command a majority in the House of Commons. This means their position is always subject to the support of their own party members (MPs). If the MPs in the governing party lose confidence in their leader, they can initiate a leadership challenge and replace the Prime Minister. Think of it like a company board deciding to change its CEO. Also, a Prime Minister can choose to resign for personal or political reasons. Finally, the most decisive way a Prime Minister can be replaced is through a General Election. If the Prime Minister's party loses the election, they must step down, and the leader of the winning party becomes the new Prime Minister. So, the Prime Minister's tenure depends on party support, personal choice, or the outcome of a general election.
Think of the Prime Minister's position as a 'political hot seat,' vulnerable to the will of their party and the electorate.