Software produced by the US Government is not automatically in the public domain; it is only so if it has been released to the public, and it was written only by Civil Servants.
Yes. Including a software license communicates to users what they can and can’t do with the software, and more importantly, informs contributors as to what rights, if any, the waive by contributing.
U.S. Government-produced code is subject to domestic and international copyright in most cases, because in most cases today, it is written by contractors, not Civil Servants. When a contractor writes code under contract to the U.S. Government, that code is covered by whatever Federal Acquisition Regulations (FAR) clauses were stipulated in the contract. There are software and data clauses that define what rights a contractor has and what rights the US Government has in any code that is ‘first produced’ under that contract. Contracts can be written such that both the contractor and the US Government have all rights to software ‘first produced’ under the contract, or the rights can stipulate that the contractor has all the rights to the software produced. Usually, the standard contract language does prevent a contractor from reselling the code produced under the contract back to any other part of the Federal Government, but that does not prevent them from selling the software commercially otherwise. That’s when it may get into technology transfer and licensing issues.
If a US Government Civil Servant produces software, then it is true that the US Government cannot assert copyright over that software, but it is also true that the software is not automatically in the public domain. As long as it is not released purposefully to the public, it is not public domain. Also, such software is not subject to a Freedom of Information Act (FOIA) request. If a Civil Servant produces software, and a Contractor has created any part of that software, the software as a whole can be subject to copyright.
While it is true that the US Government cannot assert copyrights in code or anything else, the US Government can own copyrights over code; thus, it can potentially direct a contractor to assert copyright over code produced under contract, even if some of it was written by a Civil Servant, and that copyright can then be assigned to the US Government by the contractor. If the software is released to the public, the portions written by Civil Servants are in the public domain regardless of what license is used to cover the code as a whole, but good luck being able to tell what parts were written by a Civil Servant and what parts weren’t — and you would need to tell in order to extract those portions and use them freely, unencumbered by any license.
As for licensing, software that is produced by the US Government by Civil Servant or contractor is not required to be covered under any license, OSI or otherwise, nor is it automatically in the public domain. The US Government does not have to release software to the public; it can ‘release’ software to another Federal Agency, but as long as it remains within the Federal Government (meaning Executive Branch in our case) it is still considered ‘internal’.
To release software to the public, we are required to go through a software release process. Each Agency has its own, if it has one at all. First step is to determine if the software falls under ITAR, EAR or other national security restriction that prevents release to the public. Second step is to identify all contributors to the software — if there were seven different contractors involved, we have to get copyright releases from all of them (essentially they sign saying the assert copyright but assign it to US Government, or something like that). Third, a license is chosen, these days an OSI-approved license. In reality there is more to it than these three steps, so it is not easy nor fast getting software released from the Government, generally.
To contribute openly to an open source project such as OpenBSD or Apache, our modifications are required to go through the same release process mentioned earlier. While it is possible that we could directly contribute to an open source project by cloning a git repository, making changes to the code, and submitting a pull request, in reality most Civil Servants and contractors are not allowed to do so.