I know that Germany needed the oil fields but why did hitler invade Russia. Hitler had stated in the Beginning of the war that he wouldn't have 3 frounts. By attacking kursk he went against that, and Russia had 30 million troops at their disposal
It was actually Hitler himself who argued himself in March 1941 that attacking the Soviet Union was not comparable to a 2 front war akin to WWI given that there was no danger of invasion from Great Britain.
But anyways, the reason for the attack on the Soviet Union were in large part ideological (with economic and other considerations wrapped up in that frame). An attack on the Soviet Union was sooner or later inevitable to the Nazis for two reasons:
In the warped minds of the Nazis, they were engaged in a world-wide struggle with "international Jewry", a shadowy construct of their anti-semitic minds envisioning Jews as the international force behind everything that threatened Germany. And in their delusions, the Nazis believed that the most powerful weapon of the Jews was Communism with the Soviet Union as their instrument too. So the attack on the Soviet Union was in some ways a reason d'etre for Nazi Germany, fashioning itself as the bulwark of Europe and Germandom against the Bolshevik threat.
While such consideration could be temporarily put aside as seen during the Hitler-Stalin pact, sooner or later, the invasion of the Soviet Union had to happen, just because its existence alone was perceived as an existential threat to the "German race".
The other constant in Nazi world view was the idea of Lebensraum (living space). Simply put, having seen how the old German colonial idea of establishing colonies in Africa had not worked out, another idea of the 19th century gained traction, that of Lebensraum. Basically saying that in order to be successful/survive, Germany needed new space and that space could not be found in African colonies but rather in Eastern Europe. The Nazis argued that historically and by right of their race, the space up until about the Urals was theirs for the taking, including the Ukrainian "breadbasket" and the oil fields.
Here a lot of economic considerations come into play, but ultimately the idea that the German people could neither survive nor be economically successful without living space in the East was a driving force behind the attack.
I could go on but this covers about the major basics of the reasons behind the attack. Don't hesitate to ask if you have any follow up questions.
Sources:
Johannes Hürter: Hitlers Heerführer, 2003.
Birgit Kletzin: Europa aus Rasse und Raum. Die nationalsozialistische Idee der Neuen Ordnung. 2. Auflage. Lit, Münster u. a. 2002.
Horst Boog, Jürgen Förster, Joachim Hoffmann, Ernst Klink, Rolf-Dieter Müller, Gerd R. Ueberschär: Der Angriff auf die Sowjetunion. (= Militärgeschichtliches Forschungsamt (Hrsg.): Das Deutsche Reich und der Zweite Weltkrieg, Band 4). 2. Auflage. Deutsche Verlags-Anstalt, Stuttgart 1987.
Richard Overy: Russia’s War. Blood upon the Snow. 1997.
Christian Hartmann, Johannes Hürter, Peter Lieb, Dieter Pohl: Der deutsche Krieg im Osten 1941–1944. Facetten einer Grenzüberschreitung (= Quellen und Darstellungen zur Zeitgeschichte, Band 76). R. Oldenbourg Verlag, München 2009.