The json validator for realms is too strict and doesn't allow nbt fields within strings.
These forms of loot tables will work in single player and on servers, but realms will refuse to load them:
{ "type": "minecraft:loot", "pools": [{ "rolls": 1, "entries": [{ "type": "minecraft:item", "name": "minecraft:written_book", "functions": [{ "function": "minecraft:set_nbt", "tag": "{ title:\"Book title\", author:\"Some name\", pages:[ \'\"text\"\' ] }" }] }] }] }
{ "type": "minecraft:loot", "pools": [{ "rolls": 1, "entries": [{ "type": "minecraft:item", "name": "minecraft:written_book", "functions": [{ "function": "minecraft:set_nbt", "tag": "{ title:\"Book title\", author:\"Some name\", pages:[ \'\"text\"\' ] }" }] }] }] }