You might be asking, why a pig? I don't know, but forever ago I wrote software for a cardiovascular imaging lab and pigs were their primary test subjects. I was like, "why pigs?" and the PI was like, "Imaging-wise, pig hearts aren't too different from humans. Plus, we can give them a heart attack in the scanner and not go to jail. Some labs use dogs. I just can't do that."
Originally, research was centered around non-human primates (NHPs). But it didn't work out all. Sure, they're a bit closer to us genetically, but we still reject their tissues, so we would need to genetically engineer them. Humans are also much bigger than the non-human primates we can grow in the lab with ease and that have a fast enough reproductive cycle to make genetic engineering work out. So the organs would all be undersized. Ease of breeding is a big issue too, litter sizes for NPHs are very small compared to pigs.
It gets even worse though. Because NHPs are so close to us, they easily catch infections from us. So they're much more likely to catch diseases from us and to give us their diseases.
There are also ethical concerns with primates being so close to us, which don't exist with pigs given that they're primarily food animals.
It took around a dozen or so genetic changes to knock out markers that allow our immune system to recognize that pig organs are foreign. In particular, primates (including us) are sort of strange in that Alpha-gal, a sugar that's all over all other animal bodies, doesn't exist in us and our immune system violently rejects anything that contains it. Understanding this took a long time, but then we eventually figured out how to prevent pigs from expressing Alpha-gal.
That's basically the story here. Figure out why rejection is happening, knock it out, repeat. There are also many forms of rejection and it happens differently in different tissues. But, we're getting there.
If you want to read more, here's an awesome recent review of the history and state of the field: https://www.frontiersin.org/articles/10.3389/fimmu.2019.0306...