Electronic and magnetic properties of molecular nanomagnets are determined by competing energy scales due to the crystal field splitting, the exchange interactions between transition metal atoms, and relativistic effects. We present a comprehensive theory embracing all these phenomena based on first-principles calculations. In order to achieve this goal, we start from the ${\mathrm{FeNi}}_{4}$ cluster as a paradigm. The system can be accurately described on the ab initio level yielding all expected electronic states in a range of multiplicities from 1 to 9, with a ferromagnetic ground state. By adding the spin-orbit coupling between them we obtain the zero-field splitting. This allows to introduce a spin Hamiltonian of a giant spin model, which operates on a smaller energy scale. We compare the computed parameters of this Hamiltonian with the experimental and theoretical magnetic anisotropy energies of the monolayer Ni/Cu(001). In line with them, we find that the anisotropy almost entirely originates from the second-order spin-orbit coupling, the spin-spin coupling constitutes only a small fraction. Finally, we include the ligand atoms in our consideration. This component has a decisive role for the stabilization of molecules in experimental synthesis and characterization, and also substantially complicates the theory by bringing the superexchange mechanisms into play. Since they are higher-order effects involving two hopping matrix elements, not every theory can describe them. Our generalization of the corresponding perturbation theory substantiates the use of complete active space methods for the description of superexchange. At the same time, our numerical results for the $\left\{{\mathrm{CuFe}}_{4}\right\}$ system demonstrate that the Goodenough-Kanamori rules, which are often used to determine the sign of these exchange interactions, cannot deliver quantitative predictions due to the interplay of other mechanisms, e. g., involving multicenter Coulomb integrals. We conclude by comparing ab initio values of the exchange interaction constants for the $\left\{{\mathrm{CuCu}}_{4}\right\}$ and $\left\{{\mathrm{CuFe}}_{4}\right\}$ metallacrown magnetic molecules with experimental values determined by fitting of the magnetic susceptibility curves ${\ensuremath{\chi}}_{M}T(T)$, and attribute the remaining discrepancy between them to the role of virtual electron excitations into and out of the active space (dynamical correlations).