Is it unethical to enroll in a low-ranked institution with the intention of switching to a better one if possible?
This is far from immoral or unethical. Theres nothing wrong with attending a program and transferring to another one that might be a better fit.  Making the transfer to another program would really be up to you, your work and the networking contacts you make while in your masters program.