Would it be a heavy lift for either Apple or Microsoft to maintain code so that the operating system will run on both x86 and ARM?
It is a "heavy lift" [sic]? Probably but these guys are professionals. They get paid to do this and they're supposed to be pretty good at it. This isn't something that a bunch of snot-nosed dilettantes are attempting. Sometimes in life it takes hard work to get to a better place and I'm not just talking about computing.
Anyhow that's what Apple is doing with macOS 11 Big Sur. It'll run on both Intel and Apple Silicon Macs. It's running on a bunch of unreleased stuff in secret labs, most of which will never make it to a store shelf.
My own personal belief is that Apple has been running OS X/macOS on Arm-powered devices in their labs since OS X 10.6 Snow Leopard (way back in 2010). This isn't some goofy project they came up with six months ago while having a couple of pitchers of beer at BJ's. Perhaps not coincidentally, 2010 is the same year as Apple's first custom Arm SoC -- the Apple A4 -- and the iPad. This was also around the same timeframe when Apple moved new Mac hardware releases to full 64-bit architecture.
At that time, Snow Leopard was described by Apple as a complete under-the-hood rewrite of the operating system. It had very few new features. It was the last version of OS X that supported the original Rosetta. That was ten years after OS X's debut. Now ten years later, here we are again with a major OS rewrite, so much so they gave it a new number, macOS 11.
Three years later, Apple hit another major milestone: the A7 SoC, the first 64-bit Arm CPU widely deployed in a mobile device.
Is the code for each so different that you essentially have to maintain two different versions like MacOS versus iOS?
For sure there is plenty of low-level code that is different between macOS Intel and macOS Apple Silicon. Again, Apple has probably been handling this internally for ten years.
In the similar way, many people speculated that OS X's original delay was caused by Apple's internal mandate that OS X run on both PPC and Intel CPUs, years before Apple announced their transition to the x86 architecture.
This is not Apple's first rodeo.