only when; particularly in the case of; of all times/people
Attaches to a noun and marks it as the exclusive case where something (usually negative or unexpected) happens. Often implies 'why now/this person of all times/people?' or 'it had to be this one.'
急いでいる時に限って、バスが遅れる。
The bus is late only when I'm in a hurry.
彼に限って、そんな失礼なことを言うはずがない。
He, of all people, would never say something so rude.
だけ simply means 'only,' while に限って adds a nuance of unexpectedness or irony, typically describing an unwelcome exception.
ばかり expresses 'nothing but' or a repeated occurrence, whereas に限って singles out one specific case, often implying 'why this one, of all times?'
Formed from the particle に and the te-form of the verb 限る (to limit). Literally 'limiting to', it grammaticalized into an expression meaning 'only in the case of' with an added nuance of unexpectedness.