Why also using magnetometers in IMUs?
Accelerometers can itself measure the inclination, they have a slow response.     Gyros measure angle rate change, fast response, but the problems for gyros is the zero drift and it has to be compensated for any usable application. 

While at steady state, a filter is used such that accelerometers track and eliminate the gyro drift in the vertical plane, where the gravity vector is used for inclination (roll, pitch), but in horizontal plane heading/yaw there is not such possibility, therefore magnetometer can be used. A magnetometer is mainly used for speed detection and with fusion algorithm it can eliminate the gyro offset. 

The only such known algorithm (in my knowledge) is Sebastian Madgwick's fusion algorithm. Others (Kalman filter, direct cosine matrix DCM) use accelerometer and gyros, only.