Why is MRSA resistant to beta lactams?
This protein is enconded by the mecA gene. The origin of mecA gene is unknown but it was acquired by MSSA (meticilin-susceptible staphylococcus aureus) through horizontal gene transfer to becomeMRSA (meticilin-resistant staphylococcus aureus) But it is probable that the ancestral gene comes from Staphylococcus sciuri.
There are a few conformational changes of the transpeptide domain of PBP2a compared to normal PBP as can be observed in figure below. The distorted conformation/position causes lower affinity of beta-lactam to PBP2a
 The Basis for Resistance to -Lactam Antibiotics by Penicillin binding Protein 2a of Methicillin-resistant Staphylococcus aureus, Cosimo Fuda, Maxim Suvorov, Sergei B. Vakulenko, and Shahriar Mobashery
 Antimicrobial resistance: the example of Staphylococcus aureus Franklin D. Lowy
 Structural Basis of β-Lactam Resistance in Methicillin-Resistant Strains of “Superbug” Revealed D. Lim and N.C.J. Strynadka https://www.bnl.gov/isd/documents/26322/sh_life_sci_3.pdf