It's because you're using the Vanilla Minecraft server which has horrible optimization.
I would reccomend using Spigot or PaperSpigot (higher performance) to prevent things like this. Allocate a minimum of 1GB ram. If there's lag, try allocating more ram. Still lag, try turning of multithreaded chunk loading in paper-spigot config to prevent lag.
(Using spigot/paperspigot is just like having a vanilla server, but it's super fast, and if you want, you can choose from thousands of plugins to add on)