The structural, electronic and magnetic properties of functional Ni-Mn-(Ga, In, Sn) and Pt-Ni-(Ga, Sn) alloys are studied by first-principles and Monte Carlo tools. The ab initio calculations give a basic understanding of the underlying physics which is associated with the complex magnetic behavior arising from the competition of ferro- and antiferromagnetic interactions for excess Mn atoms in the unit cell. We show that the resulting complex magnetic ordering is the driving mechanism of structural transformations and multifunctional properties of Heusler alloys associated with magnetic shape-memory, magnetocaloric and elastocaloric effects. The thermodynamic properties can be calculated by using the ab initio magnetic exchange parameters in finite-temperature Monte Carlo simulations. Entropy and specific heat changes associated with the magnetic changes and emergence of microstructure across the magnetostructural transition are pointed out. We show how to optimize the functional properties by tuning the compositional changes, for example, a magnetic shape-memory effect of more than 14% can be achieved in Pt-Ni-Mn-Ga alloys. The theoretical studies are accompanied by experimental investigations.