I don't think it is illegal per se in most countries (there may be exceptions), but that needs to be further explained.
I would think the following:
- Lying about a degree in your resume is not illegal per se, but if discovered after you got employed, it's usually a reason for breaking a work contract on a legal ground (contractually). It would be considered deceptive. Depending on the position, responsibilites and job risks, the company may not just fire you but may also sue you asking for damages.
- Working as a professional in a regulated field requiring a specific degree/credentials, such as medical doctors, civil engineeers, etc, without actually having this degree *is* illegal. The fact that you lied is an aggravating point, but even if you never objectively lied about it, assuming that you got by never being asked, just not having it makes the practice illegal.
- Actually producing a copy of a degree you don't have is producing a fake document and *is* illegal in many, if not all countries in the world.
Of course local laws may have some additional clauses about this.