Well, if the no. Of positive and negative ions were unequal, then the ionic species would have a net charge, i.e., there would be charge separation. Now since electrostatic forces (the forces that bind the cations and anions in an ionic compound) are very strong over short distances (as found in a compound), very large amount of work has to be done to separate the charges. Thus, energy required will be very high.
However, normally a system tends to be in the lowest energy state. So, unless you provide huge amounts of heat or some other external work to separate the charges, the ionic compound will have equal number of cations and anions