Is it legal and/or a good idea to let the players download the source code/project files of a comerical Unity game with the game or as a DLC?
Before you publish your sourcecode, make sure you actually have all the rights to it. Be careful about any 3rd party assets you downloaded from the Unity marketplace or elsewhere which might end up in your project. You can only publish those with the explicit permission of the creator. This also applies to stuff you got for free.
Is it a good idea?
The game sourcecode will be quite useless for most of your target demographic. Most gamers will either not be able to read the code or won't be interested in it (I would certainly not look at it - that would just be detrimental to my game experience). But there are two small sub-cultures in every game community which will have quite a lot of interest in it:
- Powergamers who want to completely understand all the game mechanics. But not all of them will need the sourcecode to do that. A few will buy the source and then create a wiki which describes all the formulas and algorithms.
- Modders, because having the sourcecode allows them to change your game in any way they want.
The second demographic is the one you might want to cater to. An active modding community can add huge value to a game.
Just make sure they don't take your base-game and offer it for free to people who haven't bought it. Any OSI-approved open source licenses explicitly allow that, so they might not be the best to protect your business interests. You might want to ask a lawyer specialized in software copyright to draft a license agreement for your sourcecode which makes sure people can use it only for documenting and modding your game.
One downside of having a strong modding community is that any DLC you release later will compete with the content offered by the modding community, so it will only sell well if you can offer a level of quality which goes far beyond what the modders are able to deliver.