This is a gyroscope, and it has too many uses.
The main use is to provide orientation.
The crucial element of the gyroscope that makes it useful for determining orientation is that it is a spinning top isolated from the rest of the world. In this way its Angular Momentum does not change. The Angular momentum appears when something starts spinning around an axis, it is a force. An example of that, is when an ice skater is spinning, if the ice skater open their arms their rotation speeds decrease, and the opposite happens when the skater bring their arms close to their body and thus angular momentum increases.
This video explains better the gyroscope works, and after see that, you can get an idea about how it works. Then, you can see the Steve Jobs video introducing a 6-axis gyroscope for the iPhone 4.