Google bought Motorola patents that came with hardware businesses attached for defense purposes, not because they wanted in on the hardware business. This was after they found themselves unarmed during a thermonuclear patent war.
Google dropped the hardware businesses and kept the patents. The patent market was notably frothy at the time, and conventional wisdom then valued Motorola's patent chest at $4.0-4.5 billion (Apple + MS consortium bought the comparable Nortel trove for a price in that ballpark). If that value is correct, then Google made a profit on buying and selling Motorola (patents + Moto Home + Moto Mobile).
Another point to consider is that Motorola has become a very healthy and popular phone brand. Especially with their inexpensive stock Android phones. Google must benefit from this as well.
Good phones running almost stock Android are useful from a marketing PoV for both positive (as a showcase for the OS) and negative (good devices that aren't running iOS/Windows/other) reasons.
Their adoption helps increase the market share of the OS so makes creating content for them (apps in the Play store, and so forth) more attractive again indirectly helping because all Android devices potentially benefit from that.
So not a profit in any easily measured $ terms, but definitely a benefit.
You can benefit from it without profiting directly. I think Google benefits from Android adoption as a whole since that usually means adoption of Google services
Some user here (seems I'm not able to find him/her) on HN mentioned that they also feared that Samsung would be switching to their own thing, dropping Android and that may have been a factor in their decision to sell Motorola as they really want to keep everyone in the Android boat.
From the blog post announcing they bought Motorola:
> We recently explained how companies including Microsoft and Apple are banding together in anti-competitive patent attacks on Android. The U.S. Department of Justice had to intervene in the results of one recent patent auction to “protect competition and innovation in the open source software community” and it is currently looking into the results of the Nortel auction. Our acquisition of Motorola will increase competition by strengthening Google’s patent portfolio, which will enable us to better protect Android from anti-competitive threats from Microsoft, Apple and other companies.
Coverage at the time, and since, in the apple-centric web focused on how Google tried to compete in hardware with Apple and failed and how they "lost" billions on the deal.
I'm sure the hardware was a bonus but at the time the purchase was primarily driven by the patents. Apple, Microsoft, Oracle , Cisco, and all the other big players have shed loads of patents for just about everything and uses them as counter measures against any potential litigation. Google at the time was lacking in such patents and was vulnerable. Motorola presented an opportunity with it's extensive cache of patents to level the playing field.
Google dropped the hardware businesses and kept the patents. The patent market was notably frothy at the time, and conventional wisdom then valued Motorola's patent chest at $4.0-4.5 billion (Apple + MS consortium bought the comparable Nortel trove for a price in that ballpark). If that value is correct, then Google made a profit on buying and selling Motorola (patents + Moto Home + Moto Mobile).