HTC and Google have been working together for a decade, and it's important to remember what that partnership has achieved. It gave us the very first Android smartphone called the HTC Dream (T-Mobile G1), the Nexus One, the Nexus 9 tablet, and most recently the Pixel smartphone. The second generation Pixel will also be a phone created with HTC. This partnership is clearly very important to Google, so Google just spent $1.1 billion in cash ensuring it continues.
In a post on the Google Blog, Google's senior vice president of hardware, Rick Osterich, both announced the deal and stated, "It's still early days for Google's hardware business." It's a clear declaration that Google is in this for the long haul and that hardware is becoming a very important part of the business, and will continue to do so for the next few decades.
As for what this deal with HTC gets Google, it boils down to talent and IP. Google selected a Pixel-focused team of talent from within HTC's organization which will move over to work for Google's hardware division. Google also gains a non-exclusive license for HTC intellectual property. It means we won't see any legal action occurring between the two companies, but also that Google can better protect itself against any other company choosing to sue over some alleged hardware-related patent infringement.
By remaining independent, HTC will continue to develop and release HTC-branded smartphones as well as HTC Vive virtual reality hardware. The company also has its sights set on the Internet of Things, augmented reality, and AI products.
The one remaining question is: why didn't Google simply acquire HTC outright? I think the simple answer to that is: it didn't need to. The two companies already work well together and have done so for a decade. Acquiring HTC would have cost billions more, faced much closer regulatory scrutiny, and likely put an end to the Vive division and any other R&D projects HTC had set in motion. Some of those may prove important in the future, so why mess with that? Google just became an even more important partner for HTC, and if they continue to innovate, that acquisition could eventually happen.
The transaction is, of course, subject to regulatory approval. Both companies expect to close by early 2018.