Im a bit late to the party but here goes:
Can anyone explain why a 5 hp 240V compressor has to be hardwired - besides "It's code"? What I'm looking for is the rational behind the requirement?
I'm not arguing the need or the code, I just wanna know the why?
It doesnt have to be hardwired. It can be plug and cord connected as long as the plug and receptacle are rated for the same or higher HP as the motor.
When it come to motor circuits, its not just about the running amps. Motors draw in-rush current that is 4x-8x FLA.
This is an enormous amount of current.
Say there is an issue with the compressor while running and it needs to be disconnected. More on that below.....
You can connect a 5hp compressor with a plug and receptacle, but they have to be designed and rated for the horsepower of the motor. The plugs and receptacles you'll commonly find at the big box store aren't. Ones that are rated for that size are designed to prevent arc flash, are very expensive, and will require a trip to your local electrical parts house.

This
Why would you get an arc flash, if it's plugged in and being controlled by the pressure switch?
Again, just trying to understand the reasoning. I appreciate that having a service disconnect is the "right" way to do it, but if you shut it off at either the pressure switch or the breaker, what's the difference?
Also, why would the inrush current on this be any different than an air conditioner that's rated for the same amp draw - and has a wall plug?
Lets say the pressure switch gets stuck in the closed position. (I've seen it happen) Person goes to unplug the compressor and they then get arcs.
Or at the end of the night, the compressor is not running, theyre tired and forget that the pressure switch is on and they go unplug the compressor. In the morning, after all the air has bled out overnight, they go to plug it in and they get a massive arc flash due to the in-rush current the motor pulls.
Only way to prevent this, is with a plug rated for the same or great HP as the motor. Theyre designed to contain the arc-flash.
The code reasoning for this is obviously safety. You imply people will always turn off the compressor with the pressure switch but remember humans are not perfect and do stupid things or they dont use their brain when theyre panicking and dont do things the proper way.
So the plugs rated for more than 3Hp are the expensive pin and sleeve type and people dont want to spend that kind of money. So the only other option is to hardwire it.
As to the air conditioner question dont recall ever seeing a window unit with a 5HP motor. Even the large 18KBtu and 24KBtu units do not have that high of a current draw.