Yes but also had the right to deny that to those who couldn't take care for themselves(can't be burden to the society). So can't stop them from coming but doesn't have to keep the freeloaders. UK choose not to pursue that but could have.
> Did the UK have the legal right to alter trading regulations? For example, could the UK decide to import chlorine washed chicken from US while in the EU?
Yes, just different legislative path. UK was full EU member since the beginning and they created those trade deals within EU and they can change them within EU. Obviously they will need to convince others about the benefits of the chlorinated chicken so they can pass that change but they also need to do the same for the electorate in the UK ehen outside of EU.
> Did the UK have a legal right to discriminate against labours from the EU who applied for jobs in the UK?
No. The idea is that meritocracy prevails, arbitrary discrimination is not OK. EU people apply for jobs freely, employers are free to chose the person who would like to work with and they can chose to work with a Brit or EU citizen if the like to. Why do you want the UK government discriminate against people and force employers to hire those they don't want to? What's wrong with meritocracy?
> EU literally does nothing and serves no purpose
EU's primary purpose is the create peace in Europe by making countries inter-depended and give common access to the resources. If you want to operate a car factory in Berlin, you don't have to conquer Berlin - you can just go there and buy or start one.
Beside this primary purpose, EU has many many more functions. It sucks or excels in some and does OK in others.