If you publish your paper on ArXiv before it is published in a peer-reviewed journal, others may steal your work and publish it peer-reviewed before you do and thus take the scientific credit. It’s difficult to attack those people since the ArXiv is not peer-reviewed.
This assumes that peer-reviewed publications determine scientific credit, which may be true in some fields but isn't universal. In mathematics, it is not relevant at all for assigning credit. Peer-reviewed papers are of course more thoroughly checked, but they do not give you any additional intellectual credit, so this difficulty does not even arise. (In particular, for assigning credit an arXiv paper beats a published paper with a nontrivially later submission date.)
For example, has a peer-reviewed journal ever withdrawn a paper because it plagiarised an ArXiv paper? Or are there well-known cases of “unpunished” plagiarism of ArXiv papers?
This is a difficult question to answer, because how could you tell? If the plagiarist doesn't copy any text, but rather just takes ideas, then it's virtually impossible to prove that anything was stolen.
In mathematics, it works like this. If someone publicly circulates a paper, then there's a brief window in which people who have made the same discovery independently have a chance to announce this fact and claim a share of the credit. They should do so more or less immediately upon learning about it.
By contrast, if too much time elapses, then the community doesn't count it as simultaneous discovery, but rather at best rediscovering something that was already known (which gives far less credit to the rediscoverer). There's not a clear cut-off for the timing, but I see it as follows: days later is definitely OK, weeks later might be OK, months later is generally not OK, a year later is definitely not OK.
The biggest weakness in this system is that there's a window in which it's possible to steal someone's ideas and claim you came up with them independently. This is certainly uncommon (indeed, claims of independent discovery are uncommon, regardless of whether they are true or false), but it's hard to know for sure how rare it is because of the difficulty of proving plagiarism of ideas. Most claims of independent discovery are obviously true (because there's a manuscript that couldn't have been written so quickly, or there's a history of talks or discussions with other researchers, or there are nontrivial variations on the ideas and applications), but every once in a while someone makes such a claim without clear evidence.
Even when there isn't much documentation, I'm inclined to believe claims of independent discovery. Faking this takes a lot of chutzpah and effort, it's not something you can get away with repeatedly, and it's an awkward situation you wouldn't want to put yourself in unnecessarily, so it seems reasonable to give people the benefit of the doubt.
In practice, I don't think the real danger is outright theft, where someone who wasn't working on this topic at all notices a new paper and says "That looks nice! I think I'll steal it." Instead, the most worrisome situation is when someone was actually working on similar ideas, but hadn't really finished sorting out the details. When they see the paper, they immediately recognize some of their ideas, and the remaining details feel so natural that they say "Yes, that's exactly what I had in mind. This paper is merely fleshing out my ideas." They honestly believe that they had practically completed this work, when they might have been somewhat further than they thought. There's a whole continuum here, from people who are basically right in their beliefs to those who are completely wrong, and it's not clear where to draw the line.
Of course I have no idea how often someone claims independent discovery based on exaggerated beliefs (again it's basically unprovable), but I imagine it happens occasionally. It's certainly unfortunate if it takes place, but it's not nearly as bad as outright theft. The worst-case scenario is having to share credit with someone who is less deserving.