I cannot speak for the situation in France. But I have a few general thoughts on the situation in Sweden, where almost 10% of the voters voted for the Anti-immigration and Anti-EU party SD (Swedish Democrats):
1) I would argue that the reason why they (SD) are gaining more and more votes is, not so much due to their own "brilliance", but due to the failure of other parties to tackle the challenges of immigration and integration. There is a disconnect in regards to what is being advertised and the real world. So, for instance, Sweden likes to brag about accepting many immigrants. All good right? Well, the other side of that coin is that Sweden, at the same time - in most serious academic studies - is singled out as one of the worst/least capable countries to integrate its immigrants. It takes, on average, 7 years for an immigrant to get his/her first job.
2) If you do not have an integrated society, you end up with areas where unemployment and crime rate skyrockets. This, in turn, creates confusion, whereby many non-immigrants get the impression that immigrants are "less capable" and are somehow "more criminal" than non-immigrants [today, ~50 % of the Swedes think that we have accepted 'too many immigrants']. You see, it's a negative cycle... And it's rooted in the fact that Government screws up immigration/integration in the first place...