This might be a stupid question but there we go.
Whenever someone explains to me WWII, they always go on about Germany/URSS invading Poland and then the rest of the countries joining the war little by little until everybody is fighting each other to win more territory. However, when I was little I always saw people and movies talking about the Holocaust as if that was the main cause of conflict between countries, and the think they fixated on. I understand now it was done because it was a horrible hate crime with no precedents in all humanity history. However, this has given me a confusion knowledge on the importance the Holocaust had during the war.
My question is, therefore, why did the Nazi party start killing jews and gypsies on top of fighting other countries for territory: was it to keep their population happy because German’s hated Jews? Or is it non-related at all with the war and something that happened on “the side”?
I don’t understand the exact link between World War II as a whole with the Holocaust and the decision to exterminate Jews.
You can't separate the war from the Holocaust because the were integral to one another. The Nazis didn't just wake up one morning and decide to do the Holocaust; it was the result of a gradual process of radicalization that started when the Nazis came to power, escalated during the prewar years, and then reached its final form because of the war. Historians now understand that the war was essential to that process of radicalization and the fact that it reached something as extreme as the Final Solution, and there are a few reasons why.
First, it's important to look at the development of Nazi Jewish policy during the prewar years. The mass murder of Jews didn't just start right off the bat when the Nazis came to power in 1933. The first steps were legalized discrimination against Jews on political, economic, and social grounds, including the infamous Nuremberg Laws and other legislation which severely curtailed the civil and economic rights of Jews in Germany. These discriminatory measures were expanded during the 1930s, and the increased discrimination prompted many Jews to leave Germany, which the Nazis saw as a desirable outcome; it's much easier to rid your society of a group of people you don't like if you can convince them to just leave on their own rather than having to physically remove them. This idea honestly worked pretty well within Germany; there were about half a million Jews in Germany in 1933, and by the time the war began, about 60% of them had already emigrated. By the late 1930s, this discrimination began to extend to outright violence against Jews, culminating in the most famous prewar pogrom in Germany, Kristallnacht, in November 1938; Jewish-owned businesses and synagogues were vandalized or destroyed throughout Germany and Austria, and over 30,000 Jews were arrested and sent to concentration camps. Many historians consider Kristallnacht to be a turning point on the road to the Final Solution because it was one of the first instances where Nazi discrimination in the social and economic spheres was translated into violence against Jews.
This is where the war comes in. The invasion of Poland had two important implications for Nazi Jewish policy. The first is that by conquering Poland, Germany dramatically increased the Jewish population living under its control. Poland had about 3.5 million Jews, while there were probably only about half a million Jews living in the Reich (Germany, Austria, and the annexed parts of Czechoslovakia) at that point. This dramatic increase in the number of Jews living under their control posed a major problem in terms of social organization, and the Germans viewed the more religious and less assimilated Jews of Eastern Europe more harshly than the more secular, assimilated Jews in Western Europe. As a result of these problems, the Nazis created ghettos in many of the major cities in Poland where the local Jewish populations were forced to live; there were probably about a thousand such ghettos during the war. These ghettos weren't intended to be the permanent solution to the "Jewish Question"; they were seen as a place where the Jews could be kept under control until a permanent solution was decided upon.
The other issue created by the invasion of Poland was that because there was now a continent-wide war going on, the prospects of eliminating the Jewish population through emigration was no longer practical. There were various ideas thrown around during this time, including creating a reservation for Jews in Poland or shipping them to Madagascar, but ultimately none of these came to fruition. In parallel with these discussions, the Nazi "euthanasia" program for people with disabilities (Aktion T4) was getting underway; this is significant both because Nazi ideology was being translated into organized, systematic mass murder and because the methods of killing these people (carbon monoxide gas chambers within the Reich, mass shooting and gas vans in Poland) were the same methods later used to kill Jews during the Final Solution.
Most historians consider the final major turning point to be the invasion of the Soviet Union, which began on 22 June 1941. Unlike the invasions of Poland and Western Europe, the Nazis explicitly framed this was as a war of racial extermination against the "subhuman" Slavic and Jewish populations of the Soviet Union, as well as a "war of ideologies" between Nazism and Bolshevism (these two ideas tied together because the Nazis believed that Jews were responsible for the creation of Soviet communism). Because of the nature of the war in the Soviet Union, mass killing of civilians was an integral part of the German invasion plans, and this project of racial extermination was a central war aim, as well as a key part of the orders given to the German forces in the Soviet Union. German troops were encouraged to deal harshly with any sign of resistance and were told that Jews were responsible for the resistance they encountered ("the partisan is where the Jew is"). This so-called "Holocaust by bullets" that was carried out by both Wehrmacht and SS personnel (as well as local collaborators) marked the beginning of genocide on a large scale with the intent of exterminating the entire Jewish "race". This demonstrates pretty clearly how the war and the Holocaust were integral to one another: the mass killings in the Soviet Union occurred during the German invasion, and they were viewed as an important part of German military strategy on the Eastern Front.
The invasion of the Soviet Union was also the point at which the development of the Final Solution began in earnest. Germany already had a large and complex network of concentration and labor camps, but the purpose-built extermination camps were not constructed until after the war with the Soviet Union began. On 31 July 1941, Göring gave Himmler an order (apparently from Hitler) to begin planning a "final solution to the Jewish question". The experiences with the mass killing of psychiatric patients (and Himmler's own revulsion after witnessing the "Holocaust by bullets") led to the creation of the extermination camps, where people would be killed by the same methods. Heydrich presented the plan for the so-called "evacuation" of the Jews at the Wannsee Conference on 20 January 1942, which is often viewed as the starting point of the Final Solution. There were already operational gassing facilities in place at Chelmno and Auschwitz, and three new camps (Belzec, Sobibor, and Treblinka) were built for the purpose of exterminating the Jews of Poland. At that point, the systematic, industrialized mass murder of the Jews in Nazi-occupied Europe began.
This process obviously consumed a significant amount of resources and cost a significant amount of money, and there's some debate over how much of a negative impact it had on the war effort, but the fact that the Nazis ignored that potential issue and pushed ahead with the extermination of the Jews even as their military situation deteriorated demonstrates that it wasn't just a side project, it was an integral part of Nazi policy at that point. The only thing that stopped the killings was the eventual military defeat of Nazi Germany and liberation of the camps. They were fully committed to the mass killings as a part of the war effort, not as something they would give up if faced with external pressure.
I realize this answer meandered a bit, but the point I want to emphasize is that the Holocaust was indelibly linked to the war. The Holocaust and the war were part of the same racial-ideological project, the goal of which was to eliminate Jewish and Slavic "subhumans" and repopulate Europe with "Aryans". The outbreak of war with Poland and the invasion of the Soviet Union were crucial turning points in the progression toward the Final Solution, and it's important to view the relationship between military conquest and racial extermination as a symbiotic one, rather than a separate or competing one.
Sources
Christopher Browning, The Origins of the Final Solution: The Evolution of Nazi Jewish Policy, September 1939-March 1942 (Random House, 2004)
David Cesarani, Final Solution: The Fate of the Jews 1933-1949 (Macmillan, 2016)
Raul Hilberg, The Destruction of the European Jews, 3rd ed. (Yale UP, 2003)
Peter Longerich, Holocaust: The Nazi Persecution and Murder of the Jews (Oxford UP, 2010)
Adding onto the answer you've already got, it is important to note that framing the Holocaust as separate from the German war effort is misunderstanding the mindset of Nazi Germany's leadership. u/commiespaceinvader addresses why we shouldn't think of them as separate.