Would replacing motherboard erase iPhone?

Yes. All the data will be lost because the memory hard disk is on the motherboard.

Can you remove the iPhone hard disk and put it into another motherboard to recover the data?

No. If we do that then the iPhone will be stuck into DFU mode and forcing you to restore (Fully erase) in iTunes. Because the data is encrypted and bound into that CPU. So the answer is NO if we just move the HDD into another device.

How to recover the data if the iPhone motherboard is totally damaged?

The motherboard can be repaired if you send it to a real specialist like us. But let say if the motherboard broken into a few pieces, we still can recover the data by transplanting the CPU and memory HDD to another motherboard. As long the CPU and memory chip is not broken then the data will be safe. I wrote an article about a transplant job before. The link at below.
https://www.iphoneservice.com.my/2019/03/damaged-iphone-data-recovery-iphone-6.html Ultimate iPhone Data Recovery - Transplant motherboard6Ultimate iPhone Data Recovery doneUltimate iPhone Data Recovery transplant job

Would replacing motherboard erase iCloud and Apple ID?

Yes. Because the Apple server recognizes your iPhone by Serial Number and IMEI. The serial number and IMEI are on the motherboard.

Can we change the serial number or IMEI without replacing the motherboard?

Yes for the serial number. The serial number is programmed into memory chip and we have tools to rewrite it.
But NO for the IMEI. IMEI is on the baseband CPU and it’s unprogrammable.