During World War 2, British, Russian, and American forces attacked and occupied Iran. Why did they occupy Iran? Why Hitler did not try to stop them?
The Invasion of Iran was carried out by British and Commonwealth forces in the south, and Soviet forces in the north. The Shah of Iran was forced to abdicate, and the new Iranian government under his son was obliged to adopt a pro-Allied stance. For the remainder of the war, Iran was occupied by Soviets in the north and British forces in the south. The occupation continued until 1946.
Why Was Iran Occupied?
It is naive to claim that Iran had nothing to do with "their war". Iran was of great strategic importance to the Allied war effort; the Allies would not tolerate a pro-German Iran.
Iran however, have a history of business with Germany, and when WW2 began, the Iranian government sought to pursue a policy of neutrality. Unfortunately, that failed to reassure the Allies. Therefore between July and August 1941, Britain issued two ultimatums demanding Germans be expelled from Iran. The Iranians refused, and the Allied invasion began on 25 August.
The main motivations of the Allies were:
Why Didn't Hitler Try to Stop it?
I'm not really sure what you expect Hitler to do. Axis forces were separated from Iran by Turkey, the Soviet Union, and British controlled Iraq. In contrast, the Allies had sizeable forces already deployed around Iran. Unfortunately, Nazi Germany had no success in developing a mass teleportation device.
Even if Hitler tried to do anything, there is nothing he could do to materially change the military situation on the ground. So no, it would not have given him "a good chance of winning the war". Even if Iran threw itself behind Nazi Germany, the military balance of power in the region was so tilted against them that it would have been little more than a rerun of what had only just happened to Iraq.
Why Weren't the Allies Questioned in Court?
I'm not sure how you imagined that could possibly happen. Or in what court that could possibly happen.
No court had jurisdiction over the Allies. None of the Allies would have agreed with your claim that it is a "crime", much less allowed Iran to take them to any court over it. And most importantly, as victors of the bloodiest war in human history, the Allies of 1945 could hardly be compelled otherwise. Even the International Court of Justice would have required their consent to have jurisdiction.
In any case, the international law prescript against the use of force in international conflicts was a development since 1945. And even now great powers still discard them at will, as evidenced by recent news. It isn't as though there actually is an international police who would come around and take you to trial.