Going all in on all-hands is clearly suboptimal, but facing such a player would be challenging - at some point, you still need to take a chance. So given optimal play, how often can you expect to beat them?
To expand on @Andrew Chin's answer, I think a good way to think about this situation is to consider multiple hands played using statistics (and a 65% chance of winning any given hand because you are playing the best ~15% of hands).
Lets assume players reload after every hand and there is no antes or blinds for simplicity.
If you played 10 hands against this person, the following graph shows the probability of winning x times:
If we add up the probabilities of winning <=5 times, the result is 0.2458. This means that you will lose or break even 24.58% of the time when you play 10 hands against this person.
Now lets take a look at what would happen if we played 100 hands against this person:
again lets count up the probability of outcomes where we lose or break even after the 100 hands are played (<= 50). The result is 0.00145, meaning if you played 100 hands against this person you would lose or break even 0.145% of the time once the 100 hands are completed.
This is a big difference! Not only is the probability of you winning greater, but your probability of winning by a more significant margin (close to 65% of the time) is greater.
Hopefully this hypothetical example provides some insight into decision making in poker when facing opponents who behave erratically. Play lots of hands, the bad beats and unlucky spots will hurt but in the long run if you have a sound strategy the math is on your side.
It depends on what you consider "optimal play".
If you open only the top 15% of hands (77+,A7s+,K9s+,QTs+,JTs,ATo+,KTo+,QJo), you have roughly 65.45% equity against a random hand.
Increasing this to the top 20% of hands (77+,A7s+,K9s+,QTs+,JTs,ATo+,KTo+,QJo), you still have roughly 63.56% equity against a random hand.
I recommend using Equilab to further explore this topic.