What historical background usually gives a nation/minority within another country legal grounds for separatism in the eyes of international community?
As PointlessSpike indicated in a comment, there isn't much "legal" basis for separatism. In international law, the only principle that can be used is the Self Determination Right, which is recognised by the United Nations. In particular, that right
states that nations based on respect for the principle of equal rights and fair equality of opportunity have the right to freely choose their sovereignty and international political status with no external compulsion or interference.
The problem here is that the definition of "nation" is pretty vague. As such, some countries have been authorised to separate according to that principle, while others have had more difficulty. It has been the basis for the decolonisation, but on the other hand, countries like Ireland have had more difficulty, and some regions/countries like the Basque are still not fully authorised to even organise a referendum for it.
As long as the borders of a state are clearly defined, the principle holds pretty well. It means, for example, that the UN can't decide which type of government is chosen in the USA. The UN can't force republics or monarchies, etc.
Separatism is more complex. You could call it a nation within a nation. So to whom do you give preference? Usually to the more influential. Spain and France are more influential on the international level than the Basque, so there isn't any enforcement of a referendum by the UN.
In the end, it is often a matter of internal politics. Quebec and Scotland have been authorised to organise a referendum to decide. Meanwhile, Catalonia has been denied a referendum (so far). After 1991, Slovenia could leave Yugoslavia quite peacefully, whereas the creation of Croatia, Bosnia and Serbia was a blood bath. And from a legal perspective, you can see that Kosovo declared itself independent, but isn't recognised by all countries.
Similarly, a few countries are recognised as such by some others, whereas others refuse to recognise them. Some examples: Taiwan, Israel, Darfur, Palestinia, etc. But that recognition is more political than legal.
From an international law perspective, the accepted answer omits an additional principle, which is probably just as important as self-determination in arguments about the legitimacy of separatism, that of the intangibility of borders (or “uti possidertis juris”).
On a theoretical level, one way to articulate a coherent account of all this is to consider that, at least since World War II, self-determination primarily applies to the large colonial empires that still existed in the 1940s (when the UN was formed) but that once that legacy is liquidated, borders should no longer be revised. That's more-or-less what the International Court of Justice ruled in its 1986 case on the border dispute between Burkina-Faso and Mali.
In that spirit, the UN has long maintained a list of non-self-governing territories, where separatism enjoys some prima facie legitimacy in the eyes of the international community. It might not be a coincidence that the most consensual and successful independence process of the last decades (East Timor) happened in a territory that originally belonged to that list.
While some of them might in part be analyzed as separatist movements, other recent “legitimate” (in the sense that they are more-or-less universally recognized as such) independence processes resulted either from the break-up of federal states (Yugoslavia, USSR) or from a referendum held with the blessing of their parent state (Slovakia, Montenegro, Eritrea, South Soudan), at least in theory (in the sense that the parent state formally agreed to the referendum, even if reluctantly, e.g. as part of a peace process).
Beyond that, international law being what it is, there are always tensions between conflicting norms and no definitive way to adjudicate disputes so that various states can maintain different views of what's legitimate or not. And the same states can alternatively emphasize one or the other principle depending on their interests or preferences (cf. e.g. Russia vs. Germany on Kosovo vs. Ukraine).
So you can find many examples of separatist movements that found some international support or went all the way to (quasi-)statehood through unilateral means, from mostly unrecognized states that are supported by a neighbor like Northern Cyprus, Nagorno-Karabakh, South Ossetia, or Abkhazia to a partially recognized but still far from consensual state like Kosovo.
In this context, some states, in part because they are concerned about their own separatist movements, prefer to maintain a strict interpretation of the uit possidertis principle and strongly resist recognizing unilateral declarations of independence. That's why Spain or many African countries do not recognize Kosovo even though they have no direct stake in this particular conflict.
You may find this blog post an interesting read: Who Gets Self-Determination?
To summarize it: There is a principle in international law that "all peoples have the right to self-determination". However, "peoples" is not defined anywhere. The principle was likely intended to be used for decolonization, not so much separatism.
So the answer to your question is that there is no good answer to your question. Everybody agrees that if the current government of a state agrees with the separation of some territory, then separatism is definitely legitimate. In all other cases, there is only successful or unsuccessful separatism (whether de facto or by getting recognized by other countries).
In the case when a country has been occupied and annexed by another, without most of the world recognizing this, the efforts of the occupied nation to regain the independence should, and time to time are, considered legitimate. At least if it is quite recent history, not 800 years ago. Any elections and referendums arranged later in these countries under gunpoint of the occupier are generally not seen as legitimate or truly representing the will of the occupied nation.
The notable example is the Baltic States (Lithuania, Latvia, Estonia) that all have been considered illegally occupied shortly before WWII by the Soviet Union, following the agreement between Soviet Union and Nazi Germany that has divided the areas of influence. Soviet Propaganda still used to call the latter struggle for independence of these countries a "separatism".
If there are any other countries in the world occupied in the similar manner, does not matter what and by whom, they struggle for the independence should also be seen as legitimate.
A world where each national entity possible to identify would have a right for the internationally observed referendum of independence would be pretty interesting but looks like currently not very much a case. Too many influential countries have regions of this kind and do not want to lose them. For instance, if China would say Crimea has the right for self-determination, then for which reason Taiwan cannot become a star number 51 in the flag of USA. Due that "we absolutely respect territorial integrity of all nations" is the most they can say.
Scope of territorial integrity:
UN Permanent Court of Justice (PCJ) 22.07.2010 Kosovo Advisory Opinion Decision:
The scope of the principle of territorial integrity is confined to the sphere of relations between States.
UN PCJ 22.07.2010, Separate opinion of Judge Cançado Trindade, p.21:
"It is for the people to determine the destiny of the territory and not the territory the destiny of the people".
"People and territory go together, but the emphasis is shifted from the status of territory to the needs and aspirations of people".
Conclusion: The PEOPLE (NATION) IN A COUNTRY other than the governing people/nation CAN SEPARATE TERRITORY of a country.
The preconditions for statehood:
UN PCJ 22.07.2010, Separate opinion of Judge Cançado Trindade, p.52:
"The preconditions for statehood in International Law remain those of an objective international law, IRRESPECTIVE OF THE "WILL" OF THE INDIVIDUAL STATES."
Conclusion: UN Members themselves CANNOT define the preconditions for statehood.
Declaration of Independence in international law:
UN PCJ 2010 Kosovo Decision and The Then-Chief of UN PCJ, 2010:
"There is NOTHING in international law that prohibits the declaration of independence (of a country)"
Note: Therefore, UN Security Council in the resolution 1983/541 covered up its illegal decision in "The Security Council CONSIDERs the declaration of independence of Turkish Republic of Northern Cyprus as legally invalid" by using the word "CONSIDER" without referring any legal basis for its thought.
The Criteria for being a PEOPLE/NATION:
UN PCJ 22.07.2010, Separate opinion of Judge Cançado Trindade, p.68 (parag. 228-29):
1. Common suffering 2. traditions and culture 3. ethnicity 4. historical ties and heritage 5. language 6. religion 7. sense of identity or kinship 8. The will to constitute a people.
The 1st criterion ("common suffering") is NOT necessary according to liberal perspective of view.
UNESCO's definition of PEOPLE: A group of individual human beings who enjoy some or all of the following common features:
1. a common historical tradition, 2. racial or ethnic identity, 3. cultural homogeneity, 4. linguistic unity, 5. religious or ideological affinity, 6. territorial connection, 7. common economic life. (WARBRICK 2002, United Nations and the Principle of International Law, p.187)
To add to the answers already given, particularly with your phrasing "in the eyes of international community":
Realism in international relations postulates that the international community is anarchic (there's no higher power to mediate), and that each state acts in its own interests in pursuit of wealth and power. Every "eye" within the international community will view separatists through the lens of their own interests. A small example is the IRA, which was supported by the Soviet Union, who in turn opposed separatist movements in their own borders.
First, in Kosovo They are kosovans that love and are loyal to Serbia. You have to know that Kosovo was a region part of serbia but it was fulled with muslims from Albania. Thats why there was a war. The serbian army went to support their loyalists people while Albania supported the albanokosovarian people with guns in order to créate a guerrilla war. Therefore, Kosovo is a divided región. One supporting the albanokosovarians and the other with serbokosovarians. So Its a very dificult situation. The cases of scotland is that for uk is a recognized nation. Not basque country not catalonia are recognized in spanish constitution. The great problem is that in 2/4 provinces of basque country are loyal to spain. And in Paisos catalans 3/4 loyal to spain and in catalonia 2/4 regiones still loyal to spain. So They are a culture nations but with minority support even in their own regions. Therefore, there is only one recognized nation, spain. Im basque but loyal to spain but I defend the fueros, our ancient constitution. I mean we are spanish but we want our own regional government.