All very laudable EV but not happening in our lifetime; or, probably, those of our grandchildren.
Compared to Russia, China or what the USA has become in the last 20 years, the EU looks positively benevolent: internally (healthcare etc) or externally (waging war cyber or real). The EU has enough teeth for defence and, frankly, that is enough for me. It had 2 nuclear powers, but 1 will do I guess.
The UN will never be able to impose 'peace, justice, rule of law (whose law ?), equality' etc on any country. It has no territory and cannot lead by example either.
The EU failings you perceive were relatively minor (IMO) and the UK had the chance to tilt the direction of the only organisation that could possibly deliver a better world, or at least our continental sized part of it.