Servo doesn't move when driven by a PIC micro controller
For the first question, your "for loops" do nothing. I know that they are here to add delays, but there is a high chance that the compiler removes them completely because they are not doing anything for it.
To remedy this, add a volatile keyword on your i variable. This would tell the compiler not to optimize things related to the i variable, such as your delay loops.
This could be the issue.

And why no using a __delay_ms() function here, instead of a for loop?

For your second question:

the program loops on itself because the MCU would some kind of reset when your main function returns.

Thus it will run your main again and reset, and run again, and reset, ....