What are legitimate reasons you say? One pertains to helping other learn and use your code. (Obviously) Second pertains to letting other people use your library and open sourcing it in order to improve the software (people have their ways with breaking things). Third pertains to the idea that open sourcing your software is in line with your ideology (assuming it is not tainted by hype), such as in the medical sector and etc. Ex. You might be a researcher who discovers something and creates/releases the code behind that something.
Illegitimate reasons? A personal project that you decided you want to open source from the start with no collaboration. (What is the point?) Open sourcing just because you read it on the internet. OS because you saw your friend do it with some success. or even open sourcing just because someone suggested you do it even though you had reasons not to.
The thing I want to point out the most is the idea of reading it and then applying it immediately. That's what hipsters do and if you are a hipster please continue else stop open sourcing just because you read it online. Polluting the internet with your code does not help anyone. O.S. = freedom of source code, but with that freedom you are also putting your ideas behind your code out there.
No one will look at your code unless the idea behind your software is interesting and if you did something simple, then it will be copied no matter what.
You might argue that Linux or Google is very successful. Just remember that you are not the exception. Linux is and many people use it.
I will keep repeating this: Don't open source just because of hype. If you've read about it, think about it.