After World War 2, some European countries decided to work closely together. They hopes that becoming closer would stop another horrible war happening again.
In 1973, Britain joined the group, to get good trade terms with the rest of Europe. Other countries also joined it, until it got quite big.
The group started out as a trade group, but gradually the main countries behind it, felt that the best way to be closer was to gradually introduce rules that would lead its members towards having similar laws and rules. That would mean that many businesses would have similar rules in all European countries, and so there would be easier trade, less to fight over, and businesses would be better and stronger. This was called "convergence", which means "becoming more alike".
A lot of people in Britain started to dislike this idea. They felt that it was too much like Europe was telling countries how to run themselves, and imposing rules on them, taking away their freedom to choose for themselves.
Gradually a big separation started to happen, between people who thought this EU ("European Union") was a good idea, people who agreed with free trade but didn't agree with becoming closer in other ways, and people who didn't like it at all. To calm voters, Britain's prime minister David Cameron promised to allow a public vote (called a "refere dum") on what should happen.
Everyone was sure Britain would vote to stay, but more than half of the voters said to leave, which caused shock and chaos. Nobody in the government had believed this would happen, so they didn't have any plans at all for what to do if people voted to leave Europe. But they felt they had to do what the vote said.
The rules for the EU are agreed by all its countries. One of the rules (called "Article 50") says that if a country wants to leave, it has to tell the other countries and then it can leave 2 years later. Britain told Europe it wanted to leave in March 2017, so it was due to leave in March 2019.
But as time went on, it became more and more difficult to work out how to leave the EU. People had made exaggerated claims about how easy leaving would be, and how much money it would save, which turned out to be completely wrong. Companies had got used to European laws and having a huge number of countries they could easily do business in. If Britain wasn't going to be in the EU, all of that - about 50 years of business and legal things - would all have to be done differently.
It turned out to be really really difficult. If British companes wanted to sell to European ones, they would have to agree to follow European standards and rules. They would maybe have to pay extra taxes for selling and buying things. Businesses that needed extra employees would not be able to employ people from other European countries.
Gradually some people started to believe that leaving was not as good an idea as they had believed, or that if it had been a good idea, it was doomed anyway because the negotiations had been done badly. Some people wanted to leave anyway,some wanted to change their mind, many people felt hurt and badly let down.
The other big problem if Britain left, was where to put the border, or boundary, between Great Britain and the rest of Europe.
Part of Great Britain is Northern Ireland. Northern Ireland had a long history of terrible terrorism and violence, which was settled and peace returned in the 1990s. One of the most important parts of that peace agreement was that both sides agreed there would be no barriers between Northern Ireland and the rest of Ireland.
But if Great Britain leaves Europe, there has to be some kind of boundary between Great Britain and Europe, with different rules on each side. This is called the "Irish backstop" problem. If you put the boundary between Northern Ireland and the rest of Ireland, you destroy the peace agreement. If you put it between Northern Ireland and the rest of Britain then you stop free trade within Britain, which also is a huge problem. But you have to have a boundary of some kind, and there just isn't an easy answer.
Faced with this, the Prime Minister Theresa May had gradually found it harder and harder to get Parliament to agree with her plan to leave Europe, until it has become almost a complete revolt.
MPs are also very divided. Some want to stay, some want to leave, some want to ask the people to vote again, some want to leave and take their chances on not having any agreement before leaving. Some see that as a complete disaster. Nobody knows what to do, and every plan suggested, has a lot of MPs who say they disagree with it.
And that's where we are, and how we got there!