Many European states used to be global powers in their own right, with colonies around the world and with major influence in trade and commerce.
That all changed after the Second World War, when the USA and USSR became the dominant global powers—joined more recently by China. For European states to maintain global influence and be treated as a super power, they had to collaborate.
There’s a 101 things wrong with the EU, the worst being the fiscal policies foisted on those states that adopted the Euro currency. And apart from the nice perks like visa free travel around Europe, and harmonisation of commercial regulations that actually cut bureaucracy and administration for businesses—its geopolitical purpose is as a bulwark against dominance by other global super powers.
The main advantage of the EU is that any member state becomes at least a modestly influential partner in a major global trading bloc, and maintains their political independence from the USA or Russia.