I don't get why whenever I repeat an algorithm 3 times the orientation of all the corners magically returns back to normal. Here is where my confusion comes. Let's say that some algorithm rotates the corner A clockwise. Now obviously if the corner is rotated in place, meaning the corner is not moved to another position, it's obvious that after another 2 repeats it will return back to normal. Bit what if the algorithm also permutes the corner. Let's say that corner B goes to A. Would it not be the case that the rotation of A is dependent on the rotation of B? Can it not be the case that on the first repeat we receive a corner rotated twice for example, meaning the total rotation in A changes. Now in such a chaotic system how can we be sure that 3 repeats always return to normal? My head hurts thinking about and I know I miss something but I can't figure it out...
I assume you are only talking about cube permutations that when repeated three times will return the corners to their original locations.
Your observation is not universally true. For example, take the following algorithm:
F2 L2 F' R' F L2 R' B' R F' R' B R2 F'
It twists the URF corner in place clockwise, cycles the other three U corners and twists one of them anti-clockwise. If you perform this three times, URF becomes solved again, but the three other U corners have each undergone one anti-clockwise twist.
You could also construct a corner permutation consisting of two 3-cycles, with one corner twist in each, but as this involves 6 corners it would not be something you would use while solving the cube. This would leave 6 twisted corners when performed three times.
If however you take any corner 3-cycle where the corners outside the 3-cycle are not twisted, then your observation holds. The twist constraint of the cube means that the three corners either all get twisted the same direction, or two of the three corners get twisted in opposite directions. In the first case performing it three times will twist each corner three times, while in the second case each corner undergoes opposing twists that cancel out.