It sounds like you want to have the cake and eat it too. Get the benefits of the union but be able to refuse the laws it imposes. If the EU decides on a law, that the majority of the union agrees on but your country doesn't, then your country has the option to leave the union.
Your country might not agree with these laws, other countries might not agree with laws regarding the environment, or human rights, etc. But the union as a whole agrees on them and if you want to benefit from the union then you have to follow.