Topology-Driven Magnetic Quantum Phase Transition in Topological Insulators