When you copy/paste code from Xcode into Keynote it includes the highlighted styling of the text.

To get rid of that background select the text then click
Text > Style > Gear drop down (grouped with Font) > Text Background > Color none.

If you do that your text will now look like this.

Feb 12, 2022 @ 02:25:21
Thank you for sharing this useful information. I am also currently using another online tool that also has the ability to remove background. They are really cool and help us a lot in our work.