There are many physics and mathematical principles behind the function of the Rubik’s Cube. There are, obviously, the underlying mechanical structures that make up the Rubik’s Cube itself which allow it to function. A ball and pivot system allows it to rotate freely (it's actually a rather intricate system, since the blocks have independent range of rotation in any direction).

However, the math behind the Rubik’s Cube is far more complex than the underpinning mechanical devices. Rubik’s Cube math falls under a category called Group Theory, which explains the math of groups of numbers and decisions that affect them. Each action you take on one individual side or square will inherently affect every other square on the cube. If you choose to move one square, it moves every other square in the associated row, throughout the entire cube.

Because of the possible moves you can make, the number of potential configurations is immeasurably vast. To calculate this number, you end up with a long factorial combination of the number of squares, faces, and possible moves, resulting in a number in the quintillions for the possible combinations.

In Group Theory, the minimum number of actions to complete a problem is typically calculated, and it is associated with the equation n*log(n), where n is the number of moves that can be made. For a Rubik’s Cube, this number is 20 moves—from any random state, it takes at minimum 20 moves to solve the Cube.This is why Rubik’s Cube competitions typically have the contestants start from a predetermined point where the remaining steps are all known, and they are timed to find the fastest and see who remembers the final steps the best. The randomness and variability in the beginning state mean that it could take literally millions of years to solve if the final sequence was unknown. Knowing this sequence makes it much simpler, because you can get the cube to a state of near completion if you know what to look for.