How is it that immune system can get rid of HPV in body and can't for Herpes? Isn't HPV more harmful and complex than Herpes? What's the difference?

Good question. The body's defense systems combats infection to eradicate from the human body, a complex interaction between the host (the body) and the invading orgsnism usually is the case, in case of Herpes, the virus remains dormant, undetected by the immne system radar in some cells and some nerve roots, once body resistance wanes for a reason or another it flares up until the body fights it back.
A matter of degree. The tendency of herpes to be recur over a lifetime is well known. It is a hardy and aggressive germ by nature, yet HPV is from the same family of viruses & might hibernate & reappear later but often doesn't. That is the nature of different germs. Some cause more trouble to our immune system. Some people carry strep in there throat year round yet never get sick, most get sick within 12hrs, it happens.