I'm planning to root my phone. So before I'm doing that I was thinking a lot about security. My question is if something goes wrong or all went right and my phone is rooted, can I change it back to old state?
Most of the time, but not always. It depends on the level of development for your device. Basically, if there isn't a custom recovery for the device or if the official firmware has not been released then probably not. If you have a Samsung, HTC, Motorola, or Sony device most likely you will be able to revert back easily.