Are you referring to countries with languages which are relatively difficult to learn for many foreigners? Or countries which aren't particularly friendly to foreign tourists? Or what?
Languages are primarily used to communicate, not discourage communication. They are also not usually unique to a single country.
People will find all sorts of reasons to create in and out groups, but I can’t imagine a country setting a policy of limiting learning of their official language. To protect their culture they’d want it learned so it doesn’t get supplanted by another external language.