From a software developer standpoint, the purpose of a software licence key is to prevent the developer’s software from being copied, shared or otherwise illegally used (aka pirated) by non-licensed users. The basic idea is that only users that have acquired the appropriate licence will be issued with a licence key enabling them to install or use the software.
Software licence keys are used in various copy protection schemes.