Why is some ionic substance insoluble, such as BaSO4?
The electronegativity is not the main factor. The entropy factor is much more important. When a salt like $\ce{BaSO_4}$  tries to get dissolved, its ions are attracting water molecules that get fixed or attached around each ion. This phenomena creates order, and decreases the entropy of the solution. The same thing happens around sulfate ions $\ce{SO_4^{2-}}$. If there is too much water attached around each ion, the substance does not dissolve. This is the case for $\ce{BaSO_4}$, because the ion $\ce{Ba^{2+}}$ is bigger than $\ce{Mg^{2+}}$, and so creates more order in attracting more water molecules around it. The entropy decreases too much if $\ce{BaSO_4}$ gets dissolved. This salt is practically not soluble. This is not the case for $\ce{MgSO_4}$.