The 1st amendment doesn't protect you from consequences of your speech, even if those consequences are given by the government. A person admitting to a crime on a TV program isn't protected under free speech (or even 5th amendment/self-incrimination). If you own a website which talks about legalisation of narcotics, that doesn't protect you from the DEA from denying you a job as an agent because of your free speech rights.
He had no right to enter the US. They could deny him for any reason, technically. His right to free speech has nothing to do with it. However, that doesn't mean that they should have denied him for such an idiotic reason, or that they were acting reasonably. Huge difference.
If immigration officers can't understand context, I am not sure how confident we could be that they'd understand any real threat expressed in any nuanced manner which was not an out and out statement of intent.