There are lots of facets to this question and the answer is by no means straightforward. Here are a few of my thought but by no means a comprehensive answer:
I am astounded that any country wishes to subscribe to the idea of paying benefits to non Nationals. It seems to be totally unfair. Freedom to seek work in another country is one thing, freedom to move in and be supported by it is another. A fairer way would be for Europe to set up a system whereby the country that the worker moves from, reimburses the cost of the benefits, health, education and housings costs, to the host country for a set number of years.
If as a pensioner I move to a European country, my state pension follows me rather than my getting the local rate, so why not the unemployment benefit?
A country needs to be predominately ruled by justice. If a country pays to educate and train a child for about 20 years, then that child should not be paid to sit at home while there is a job it could do, and no company should employ someone from another country while there are unemployed people who could do the job sitting at home doing nothing. This means a change in attitude by the unemployed here as well as the businesses that employ them. The unemployed person need to be willing to travel, and be supported to do so if necessary. A related issue is that wages should be such that the government does not have to subsidise the worker via tax credits and housing benefits, which is, in effect, a subsidy to the employer (as is the case with Amazon, for example).
To me a better idea is for more businesses to move to the European countries where jobs are scarce - surely transport, wages etc would be cheaper for them than in the UK?
Some of the Eastern European countries are being left with a shortage of young, hard working people to help contribute to their country's income and support the older generation.
Perhaps we OAP's should move out and establish communities in countries like Latvia, Romania, etc which I understand are beautiful countries with lots of space.
The other side of the coin is that the UK should not be taking nurses and doctors that poorer countries have trained, to work in our hospitals. These poorer countries surely need them more than we do, but if not, then we should reimburse the government that trained them.