I cannot compile the Arduino sketch when I remove the void loop function?
You can't, and shouldn't, remove the loop function. Arduino sketches must have a setup function and a loop function. The setup function is called once and the loop function is called repeatedly.

Just make your loop function look like this:

void loop() {
    movefor ();
    moveback ();
}


Your motor will move forward, then move backwards, forever.

Note that you should read up on how to avoid using the delay function. You really need to use millis() to do your timing rather than delays. Do an internet search on "Arduino blink no delay." That's basic Arduino programming.