Yes, it was very clever. The old school Far Left Dems and the new school Super Far Left Dems were having a nasty little war between themselves to see who would be the face of the Democratic Party. Most people in Trump's position would just say "wonderful". Do nothing and enjoy watching them tear each other apart.
But Trump wants the Super Far Left crazies to be the face of the Dem Party for 2020, so he makes a comment which assures that every Dem has to rally behind the odd squad. It's completely irrelevant whether the comments are or aren't racist. They were intended to make everyone FREAK OUT! about RACISM! and get in line behind those four radical ladies, and it worked. It also keeps them in the headlines, which is great for Trump, and he's no doubt aware of recent polling showing that the more Americans hear from these ladies, the less they like them. And that's why Trump's been tweeting about the incident every day since his original tweet. If it were possible, I'm sure he'd like to tweet about this every half hour for the next year.
Plus, although it couldn't have been anticipated, Trump got the extra bonus of the Democrats nearly descending into anarchy of the floor of the House. And these people want to govern us?
In the past when I've heard Trump supporters say he plays "4D chess" I've always been dubious about it, but this time, yeah, it was clever.