While security and equal treatment are aspects of border control it’s primary purpose is population control. It’s to control not just numbers but also to be certain your country only brings in the best. If you don’t bring anything of value a society does not have to accept you particularly if that society would have to provide for you when you can’t provide for yourself.
Seeing as every society has an obligation to those born into that society they should not have to take on the excess burden of other societies. Forcing a society to accept people is another form of collectivism as long as welfare programs exist. It forces a society to give up its resources to members of poorer societies forcefully. A societie’s only obligation is to its contributing members of it and the helpless born into it.
Open borders forces wealthier societies to surrender their resources to the helpless and low quality of other countries, accept things that they may not want in society, and brings in an influx of people that at an uncontrolled growth rate infrastructure may not be able to keep up with. It’s dangerous for an established society.
Controlled borders are healthy. Just as all people are granted the freedom of association so is a whole society. This includes the right to not associate with some. This does not mean societies can exclude those born into them, but they can if they do something heinous and this is why jail is justified. While yes jail should be dedicated to rehabilitation sometimes elements must be completely removed from it to protect it. This is also why we should keep prisoners who commit crimes in our country even foreigners. Other countries can just as easily exile them as we can. Which with open borders would allow removed elements to sneak back in.
Now that does not mean open borders can’t exist. It just needs to be mutually beneficial for both countries. This can be done with treaties such as the US Constitution. That being said such treaties are only viable when a country can pull out and secede from an open borders community.
Having healthy boundaries is an important part in human psychology. This same psychology applies to states. The secret isn’t in having full open borders because there are now boundaries, it doesn’t allow societies to pull away from what they find detestable. No it is in flexible systems of open borders with degrees of control across all borders. Societies should constantly be shifting and changing alliances to adapt to the development of culture. The rights of sovereign states need to be protected and that means their right to consent to being part of system as well.