I still have a hard time believing that they ever showed that episode to kids on purpose and that Ringo Starr agreed to do that one 😬😄
I think there’s some useful context, if not a good defence of this story.
It’s one of the original stories told by Reverend Awdry told to his 2 year old, measles-ridden child in 1942 war-era England (Wait, is this making it worse?).
Awdry would sing/recite old poems to Christopher, who then pressed him for further details that turned into a story.
For example, the opening of that episode of Thomas features the Limerick that prompted the story, which was around at least since 1902:
In the original story by Awdry, there is only a single tunnel, and the train is completely blocking the line and essentially ruining a business. So stubborn is the engine, that they have to dig a new tunnel beside the old one. The rails are removed and “a wall” are placed in front of the tunnel, for safety - to prevent trains literally running into the wrong tunnel and crashing. The Fat Director/Controller is also pretty unsympathetic deliberately - he commands people to push and pull the train out without success, but doesn’t himself help - “My doctor has forbidden me to push”. However the original books follow the realities of steam engine and railway operation far more closely than the TV series did (and as a result, the original series, closer to the books, were far more realistic than the later ones).
As portrayed in the TV show it definitely comes off more villainous. But in the original telling we have to take away 70 years of Thomas trains having faces, personalities, relationships and familiarity. When originally told, the Henry story didn’t even take place in the same “universe” - there was just 3 abstract stories about trains, loosely based on old rhymes and news stories.
A lot of people not familiar with Thomas also don’t realize Henry is let out of the tunnel in the following episode of the TV series. Many people think Henry really was bricked up for always, and always, and always. But the truth is that it was to teach Henry a lesson for letting his vanity cause significant problems for the entire island.
To expand on that point, Sir Topham Hatt isn’t being cruel (though as you mentioned he’s not exactly being nice either), he’s punishing an engine for jeopardizing the entire railway and putting the livelihoods of all of the other engines and employees at risk. The main line is critical for the railway’s operation, as without it, there’s no Express, no access to branch lines, and no way to deliver goods and passengers. Without a railway, they’d be out of a job and possibly scrapped, a fate that most engines outside of Sodor meet. And in addition to that, the island of Sodor is heavily reliant on the railway to function and is a major employer in the region. The railway going under would cause economic havok for the whole island. Topham knows this and had to take drastic measures to teach Henry the error of his ways.