Why does the object move when clearing its parent?
As stated in my comment, I'm pretty sure you can fix this by using Alt+P and selecting "Clear and keep transformation". This way it should clear the parent and keep its location.

What happens in your example is that when you remove the parent like that, your object jumps back to the original location/rotation it was in before it was parented to something.