Disable PVP in Minecraft with a command
Solution 1:
You can use the weakness effect which when having a high strength does not allow the player to deal any damage. /effect give @a weakness 9999 255 true
will give weakness 255 to all players until you clear it and also hide the bubbles to make sure they don't annoy anyone.
Note for Bedrock Edition players:
There is a gamerule command /gamerule pvp false
which will disable PVP.