There are two key points I'd like to add to this.
First, it is unlikely that this bug would be fixed. The Scripting API has hardly been updated, and given the GameTests that the team has been working on, the Scripting API is mostly useless. Developers from Mojang have also stated during a GameTest Q+A that there would be plans to remove the Scripting API entirely.
Second, relating to the bug report, notice that this report was written for the Linux/Ubuntu distribution of the BDS software. Throughout many tests and discussions, the add-on community noticed that server scripts did in fact work on the Windows distribution of BDS, but did not work on the Linux version. Additionally, as Realms use the Linux version, server scripts did not work on realms either. While it has been marked as Incomplete, the best bug report I can find that mentions this as well is BDS-11490.
I just want to mention that this doesn't just affect realms, it appears to affect BDS as well.
These are a few notes I've managed to gather with BDS, I'm not entirely sure how accurate they are:
Unfortunately with the server, I've been unable to reproduce this, but I know for a fact that others have experienced this and have tried to find a cause, to no avail.
Windows/Ubuntu is odd. If I'm not mistaken, realms are based off of the Linux distribution of BDS, and all the people I've talked to who have experienced this also have used this distribution. It wouldn't be the first time a disparity occurred between Linux and Windows, such as the now removed Scripting API.
The odd thing is that even though I suspected this, when I went to test for myself, the GameTest script work flawlessly.
We've attempted to explain it via having two modules, one of the data type and one of the script type. We've attempted if having multiple packs affected it. We've attempted if certain experimental toggles affected it. We've attempted different world settings, and we've attempted using a simpler script instead to see if certain commands cause it to fail. We've attempted converting worlds between 1.18.30 and 1.19.
All of these attempts got us no closer to finding an answer.
As of now, the only thing I can think of that could even possibly cause this is the machine. Maybe the OS version? Or maybe something to do with the hardware, like CPU and GPU? Or perhaps, just pure randomness, but that seems unlikely given the vast amount of testing I've done already, all of which ended with the same result.
Update 2022/06/09 12:27 CDT
I've now tested the servers running on Ubuntu 18.04, 21.10, and 22.04 in addition to the 20.04 that I've already attempted. I've still been unable to pinpoint an exact cause, as none of them allowed me to reproduce this issue.