Is it legal for the company to change the place where employees pay social security privately?

Legally speaking, your medical insurance must be paid and managed by your unit. As long as he does not stop your medical insurance, it is not illegal.

If you don't want medical insurance in city B, you can ask your company to continue to want medical insurance in city A, and they can transfer it back to you.

I analyzed the reason why your company changed cities and re-insured you.

1The companies in cities A and B may be parent-subsidiary companies, so it is normal to transfer insurance.

The treatment in city B is lower than that in city A to reduce the company's expenses.