Ticking "unknown sources" or the option itself isn't illegal, if that's what worries you. Google's Play store's got countless apps available for us, android users. But every now and then there are apps/games/themes/and what not that aren't listed there. Be it because Google couldn't reach an agreement with the authours or there may be other reasons. You would probably get the best answer regarding the subject if you were to turn to the source, namely Google developers them selves. Anyhow, the decision to let software from "unknown sources" be installed on our devices is on us to make. And as i've said before, i tick "unknown sources" on all my android devices and never have i regreted it by it posing any sort of problems. Bottom line: "unknown sources" lets you install software that is not listed on Play store. If you have at some point downloaded apps from any "third party" source it doesn't matter that Play store has it listed. The fact of the matter is, you wouldn't have been able to install it on your device anyway if "unknown sources" were unticked (factory set default). I promise you, Google won't hold it against you though they do tend to "rub it in" a bit by "advising" you not to do that or at least being careful if not familiar with it, which on itself isn't such a bad thing after all.
If you feel i didn't answer your question please do tell.
Almost forgot.. One thing is ticking "unknown sources" and something completely different is downloading and installing materials that could actually be illegal in some countries. Additionaly, if, down the line, you "break" your device by allowing a "third party" app to do havock in the system files, use your device for purposes of hacking, phishing or some other nasty ILLEGAL business, you COULD be held accounted for by voiding the warranty. Also, there are apps out there that can do some serious damage to your wallet by sending sms, mms, emails, making calls etc. A piece of advice.. There is nothing wrong by wanting to get more outta your android device as long as you do some research about the specific software, read comments, Google it, ask about it in forums and so on.