Great Britain was the pre-eminent 'empire' in economic, political and military power up until about the first world war. The military power was based mainly on naval superiority for protecting our overseas empire with a mediocre army. But from that point onwards it was in decline. We did not realise it until the second world war when the full industrial power of the United Status make itself felt. Winston Churchill may have sat with Roosevelt and Stalin but even he know that we was the junior partner in the talks.
Even after WW2 we had an outsized political influence because of our special relationship with the USA and influence with many ex-colonies. The UN security council was setup with five permanent seats, the five countries that at the time had nuclear weapons (USA, Russia, China, France, UK). Obviously the UK is not likely to vote itself off of that council and they have veto power.
The Brexit vote is based purely on the issue of immigration. Part of being in the UN is that all people from the EU countries can travel and work freely within any of the countries. Given that English is a very popular second language in the poorer countries you can see that many of them come to the UK to try for a better life. I would do the same in their position. Imagine if the USA joined in union with Mexico and part of that meant the border between USA and Mexico was completely open. Do you think there might be a large number of people moving to America and do you think that would cause stress on the education, health system and resentment from the local population? I think it would and so it has with the UK population. Add on top that the British have never really liked the Europeans very much and that much of the EU is actually controlled by a German/French power block and you have plenty of people who want out.