Android is a free open-source operating system. The AOSP (Android Open Source Project) is free to download, free to alter, free to build into a product that can power just about anything. But it's probably not something you've ever used when you picked up a phone or other gizmo that runs "Android".
Android is not a thing as much as something you use to make a thing.
At its heart, Android is nothing more than a platform that anyone can use to run applications plus the bits and pieces needed for it to talk to standard hardware. We tend to think of Android as an operating system for a phone or tablet (or even a watch or television), but it's just a part of the software needed to get any device to turn on and do things. That being said, it's one of the most important parts.
Having a huge library of code that anyone can use is great. Having all the things people build with it able to use the same applications is even better. It's better for us because we will have a huge list of applications that work out of the box when we buy an Android-powered device. It's better for the companies making the devices because we'll want to buy them and they don't have to put in the work to build their own application platform. It's also great for Google because it means more devices will be able to use the internet and its services.
That last part is why Google maintains the AOSP. Google has always held the belief that everyone should have access to the internet. While some of the reasons may be altruistic and good-natured, the main reason Google as a company has these goals is because the internet is how it makes money. All companies exist to make mone, but with the AOSP, Google has found a new way to make money from everyone while giving away one of its most expensive products: Android.
This is done through the AOSP. Google maintains the Android source code. That means exactly what you think it does: It keeps things clean and tidy and up-to-date, then makes it available for other people. It also has people working full time to make improvements and add new features to Android. All of this is made available for anyone to freely use under a liberal license that allows changes to be made to the code and not submitted back to the maintainers. Samsung is allowed to do whatever it wants with the AOSP. So are you, and so am I. If we do something different, we can keep those changes to ourselves to offer a (hopefully) better product than anyone else can.
But the phones and gadgets we buy aren't running the AOSP as an operating system. What we see is the end result of someone or some company using it to create software that is unique and their own. This can be done by changing the code or by adding more code or even adding applications that aren't open sourced like the AOSP is. Every company that sells Android-powered gadgets, including Google itself, is doing this. But even this fits into Google's methods to make money because there are some restrictions when a company wants to use Google's popular applications and services.
The process is a circle. Google gives Android away. A company uses it on its phone. As consumers, we want Android phones that can use Google Play and Gmail and Google Photos and all the other things that make Android great. The company making the phone can bundle those features in for free as long as it makes sure its product can use every other application found in the Google Play store. Phone manufacturers, like Samsung, save time and money by not building their own application platform and application storefront; we get a phone with access to all the apps we love plus a market with over a million others, and Google gets a lot of people using its services and being on the internet to see Google's ads.
By making Android a big piece of an operating system that anyone can use for free, Google's investment in it pays off.
This couldn't happen without Android being free to use, so the time and money Google invests in Android makes it a very lucrative part of its business. By providing Android as source code anyone can use instead of a standalone product like Windows, Google can reap the benefits while another company does the work of building and maintaining a living operating system. AOSP means everyone wins, and that's the way we like it.