Solution 1:

It's not an idiom (meaning not inferable from the parts) or a set phrase (a special phrase that people have used often, usually literal or obvious metaphor but has more to it). It is a new turn of phrase putting two things together that are not common or common together so it stands out.

'Basket' is used as a metaphor/metonymy of 'grouping', like 'a bunch'. 'Deplorables' is the use of an adjective (an attribute) as a collective noun (the defining sense of the group) which is a small synecdoche (in English).

The vague disparagement of the phrase comes from a few things:

  • 'Basket', an everyday object (though not particular common these days given technology) evokes some faint connections with phrases that are somewhat disparaging like "bag of hair". The most common uses of the words are in proverbs/sayings like "Don't put all your eggs in one basket" and "Going to hell in a hand basket"
  • 'Deplorable' is one of many fancy words terrible. It can act a little euphemistically because the word is educated and therefore unclear in informal contexts.
  • 'Basket' and 'deplorable' come from very contrasting registers. 'Basket' is somewhat pedestrian, everyday, humble. 'Deplorable' is erudite, high-brow.
  • The phrase has the pattern of a 'group of things' which has the subtle distancing and objectification like 'the X' instead of just 'X'. It even evokes terms of venery like 'pack of dogs', and even more like the humorous made up ones like 'murder of crows'

But that is a semantic, connotative analysis. The real controversy is the political context.