X5 rear doors don't open with Remote.
If the other doors work fine, and the tailgate works intermittently, the door lock actuator in the tailgate is likely weak and/or failing. Have it replaced. But first, rule out a loose connection in the rear gate, in case someone has been in there already for some other reason.
Search BMW X5 Questions
BMW X5 Experts