Ideality of solutions is analogous to ideality for gases, with the important difference that intermolecular interactions in liquids are strong and cannot simply be neglected as they can for ideal gases.  Instead we assume that the mean strength of the interactions are the same between all the molecules of the solution.
More formally, for a mix of molecules of A and B, then the interactions between unlike neighbors (U) and like neighbors U and U  must be of the same average strength, i.e., 2 U = U + U and the longer-range interactions must be nil (or at least indistinguishable).  If the molecular forces are the same between AA, AB and BB, i.e., U = U = U, then the solution is automatically ideal.
If the molecules are almost identical chemically, e.g., 1-butanol and 2-butanol, then the solution will be almost ideal.  Since the interaction energies between A and B are almost equal, it follows that there is only a very small overall energy (enthalpy) change when the substances are mixed.  The more dissimilar the nature of A and B, the more strongly the solution is expected to deviate from ideality.