I think the reason is that UIKit was created based on the Objective-C programming language, before the people developing UIKit even knew that Swift would come along and make everything easier. So, they were basically taking a language created in the early '80s, and trying to figure out how they could create tools from the Objective-C foundation that would make it easier to make User Interfaces with it in the early '00s.
The people creating Objective-C in the early '80s didn't have the foresight to create the language to be easily used for creating graphical user interfaces, and probably didn't think that it would need to be used for much more than presenting text on screens. So, building this bridge was far from an easy task, and still required using some really messy looking code along the way.
HTML however, was created in the early '90s with a specific goal in mind. (To be able to display pages that could be sent over the internet.) So, they were able to create it in the simplest way that they could think of that would allow a person to accomplish that goal. They didn't have to make it integrate with another 20 year old language.
Not too long after UIKit was released, people probably started to think that there must be a better way, and began development on the Swift programming language. And now we have SwiftUI from it, which makes it possible to condense a lot more into single lines of code. But the developers of Swift and SwiftUI had the advantage of knowing a lot more about what modern day use cases for the language would be, and make it a lot easier for developers to use for those use cases.