Yes, that's how nations work. Otherwise you end up paying for the world's social security while not collecting everyone's taxes.
Yeah it's much better to make your money by enabling the worlds worst dictators to steal money from their populations. In fact it's all the other countries taxes that are paying for the swiss social security, because of all the aid money being funneled into swiss bank accounts.
Who's paying for what social services is an entirely different question, that is in fact being currently renegotiated:
https://www.swissinfo.ch/eng/swiss-politics/swiss-warn-eu-jo...
This thread is about migration and residence, not benefits.