Why is the divergence of a magnetic field equal to zero?

Your intuition about the meaning of the divergence operator is wrong.

In physics it's easiest to think intuitively about divergence by using the divergence theorem which states

$$\int_V dV \ \nabla \cdot \mathbf{B} = \int_{\partial V} \mathbf{B} \cdot d\mathbf{S}$$

where $\partial V$ is the surface area surrounding the volume $V$. The magnetic field has zero divergence, which means that

$$\int_{\partial V} \mathbf{B} \cdot d\mathbf{S}= 0$$

We can interpret this by saying there's no net flow of magnetic field across any closed surface. This makes sense because magnetic field lines always come in complete loops, rather than starting or ending at a point.

Put another way, the divergence-free condition is just saying that we don't have magnetic monopoles in Maxwell electromagnetism.

Let me know if you need any more help!


Divergence means the field is either converging to a point/source or diverging from it.

Divergence of magnetic field is zero everywhere because if it is not it would mean that a monopole is there since field can converge to or diverge from monopole. But magnetic monopole doesn't exist in space. So its divergence is zero everywhere.

Mathematically, we get divergence of electric field also zero without the delta function correction. In this case electric monopole exists in space i.e., positive charge or negative charge, and divergence is not zero wherever there is point charge or source, because field is converging to or diverging from that point/source. so after the delta function correction we get the correct result for divergence of electric field.