Why does a body topple over only when the perpendicular from its
centre of gravity does not pass through its base
One of the requirements for static equilibrium is that the sum of the moments about any point has to equal zero, otherwise there will be rotation. When the perpendicular from the center of gravity of an object does not pass through its base, if there are no other external forces there will be a net moment about base due to its weight and the object will topple.
See the diagram below. Given that the only external force acting on the object is its weight, once the perpendicular through the CG goes beyond point A on the base, there will be a net clock wise moment about A and toppling occurs. When the perpendicular just intersects A, the structure is unstable and toppling is imminent.
Hope this helps.