Adsorbed molecules can modulate the behavior of magnesium (Mg) and Mg alloy in biomedical applications. The interaction regularity and mechanism of biomolecules (such as amino acids, dipeptides, and tripeptide) on a Mg(0001) surface, the influence of dipole correction, and the effects of alloying elements and electronic structure were investigated in this study using first-principles calculations. Specifically, the adsorption energy (Eads) of functional groups (-NH2, -COOH and -CN3H4), amino acids (arginine (Arg), glycine (Gly), and aspartic acid (Asp)), dipeptides (arginine–glycine (Arg-Gly), glycine–aspartic acid (Gly-Asp), and arginine–aspartic acid (Arg-Asp)), and arginine–glycine–aspartic acid (RGD) tripeptide were systematically calculated. Dipole correction slightly enhanced the interaction between molecules and Mg surfaces, but the Eads trend remained unchanged. The addition of alloying elements improved the interaction of molecules and Mg-based alloy surfaces. This study will be of fundamental importance in understanding the interaction regularity of molecules on Mg and Mg-based alloy surfaces and provide possibilities for surface modification design of biomedical materials.