What happens when a Member of Parliament (MP) dies or resigns?

Okay, so when a Member of Parliament, or MP, leaves their position either through death or resignation, it creates a vacancy that needs to be filled promptly. The UK operates under a representative democracy, meaning each geographical area, called a constituency, elects an MP to represent their interests in Parliament. Leaving a constituency without representation for an extended period would be undemocratic. That's why a "by-election" is held. Think of it as a mini-election just for that specific constituency. All the political parties, and sometimes independent candidates, will put forward a candidate, and the people living in that constituency get to vote for who they want to represent them in Parliament until the next general election. It's important to remember that the party of the departing MP doesn't automatically get to choose the replacement; it's up to the voters in that constituency to decide. Waiting until the next general election, which could be years away, or having another MP cover the area, would leave the constituency without its own dedicated voice in Parliament.
When an MP leaves, the constituency needs a new voice. A 'by-election' is called to let the people choose their new representative.