The influence of magnetic ordering on the stability of Ni-Mn-Ga(-Co-Cu) Heusler alloys is investigated using the first-principles exact muffin-tin orbital method in combination with the coherent-potential approximation. The paramagnetic (PM) state is described by disordered local moment approach. In stoichiometric Ni2MnGa alloy, the total energy profile along the tetragonal deformation path differs between ferromagnetic (FM) ground state and PM state with high energy, where cubic structure of austenite exhibits lower total energy than tetragonally distorted structure of martensite. Martensitic structure is stabilized in ground state by FM interaction. In PM state it can be stabilized by partial substitution of Ni by Co or by partial substitution of Mn/Ga by Cu. Energy difference between PM and FM state ΔEPM-FM can be used for qualitative estimation of Curie temperature TC. Since Co doping to Ni sublattice slightly increases ΔEPM-FM, the TC should also increase, which corresponds to experimental findings. Analogically, Cu doping to Mn sublattice strongly decreases ΔEPM-FM, which corresponds to strong decrease of TC, also confirmed experimentally. For Cu doping in Ga sublattice the decrease in TC is weaker.