If the justice system turns out not to be as independent as one would have hoped (especially relative to the executive), parliamentary immunity acts as a safeguard for the legislators' independence:
a regime of parliamentary inviolability is necessary in countries that do not provide their parliamentarians with adequate means of protection, especially because their judicial and criminal justice system provides insufficient safeguards, since it constitutes an important safeguard for the political minority and the opposition
[...]
[Usually, in democracies] it is the parliamentary opposition which is in danger of undue pressure. The rules on parliamentary immunity today function primarily as a minority guarantee.
On the other hand...
The Venice Commission observes that the main argument against parliamentary immunity is the principle of equality of all citizens before the law, one of the foundations of the rule of law: “Any form of parliamentary immunity by definition means that members of parliament are given a special legal protection that other citizens do not have. For democracy to function it is particularly important that the members of the legislature themselves stick strictly to the laws that they make for others and that they can be held both politically and legally accountable for their actions. Rules on parliamentary immunity are an obstacle to this, and they are open to misuse and the obstruction of justice. By their very existence they may also contribute to undermining public confidence in parliament and to creating contempt for politicians and for the democratic system as such.”
The degree of immunity (in the inviolability sub-sense) varies in countries in Europe, e.g.
The traditional model of parliamentary immunity is currently being called into question. Several countries (Estonia, the Slovak Republic and Ukraine) have chosen the path leading to a significant reduction or even the repealing of inviolability. By doing so, they will join a number of countries where traditional inviolability does not exist (the Netherlands, the United Kingdom) or is interpreted narrowly (Sweden).
And if you're curious about some EP stats in that regard:
Since 1974, the European Parliament has dealt with a number of requests to waive immunity. Statistics show that “between 1979 – when direct elections to the EP were held for the first time – and the 2009 elections, 157 immunity cases were discussed in the plenary. In 45 out of these 157 cases, immunity was waived or an MEP’s immunity not defended”. [...]
The CJEU has accepted that “the parliament has a broad discretion when deciding whether to grant or to refuse a request for waiver of immunity or defence of immunity, owing to the political nature of such a decision”.
[....]
Fumus persecutionis is the presumption that a judicial action has been brought with the intention of causing the member political damage.
There quite a enough examples of this in the report even in "established democracies". The report I quoted that from briefly illustrates it with cases from France, Germany, Italy and Poland.
(As an aside, I guess generating fumus persecutionis is what Democrats say Trump was after in the recent US impeachment drama.)
The (COE) report also has an interesting section on "prosecution of members of pro-autonomy or separatist parties", which would be most relevant to the example you've invoked.
As the European Court of Human Rights has emphasised, “one of the principal characteristics of democracy is the possibility it offers of resolving a country's problems through dialogue, without recourse to violence, even when they are irksome”. In a normal situation, “there can be no justification for hindering a political group solely because it seeks to debate in public the situation of part of the State's population and to take part in the nation's political life in order to find, according to democratic rules, solutions capable of satisfying everyone concerned”. [...]
The Court confirmed this position in its Stankov and the United Macedonian Organisation Ilinden v. Bulgaria judgment concerning the ban of a peaceful meeting of a Macedonian minority in Bulgaria. [...] In particular, the Court stated that “[d]emanding territorial changes in speeches and demonstrations does not automatically amount to a threat to the country’s territorial integrity and national security”.
I guess they might end up having to decide where organizing a referendum fits into that.
Beyond that we get into a discussion whether the branches should be co-equal or not in various other ways. See also "judicial supremacy" vs. "parliamentary supremacy" etc.