It’s very likely that it simply takes very very long for the for loop to run.
It take Chunk.Width * Chunk.Height * Chunk.Length iterations to run the loop, now if those numbers are large, it could cause unity to seem frozen while it’s running those iterations. Now, Debug.Log is an IO operation which is relatively expensive, so running it 500 x 500 x 500 times will take a long time. And if you do this every frame, then that makes it even worse…
The reason that this doesn’t happen when you have no commands inside the for is simple. The compiler recognizes that nothing whatsoever happens in the for, so it optimizes it by removing the code completely.
If I’m right, first thing you’d want to do is remove the logs because they are a heavy operation. If it still feels stuck, then your design has a performance flaw. Either make the loops smaller, or do them only once in the Start() method, and simply wait for them to finish.