WordPress was written and released under a GPL licence. As explained below.
GPL (General Public License) is a type of license that software developers use to release their software to the public. The GPL license allows users to access, use, and modify the software for free. It gives users the freedom to study, change, and distribute the software as they see fit.
When software is released under the GPL license, it means that the source code is available for anyone to access and modify. This allows users to make changes to the software to suit their specific needs or preferences. When someone creates a modified version of the software, they are required to release it under the same GPL license, so that others can continue to access and modify the software for free.
The reason software released under the GPL license can be free is because the license ensures that the software remains free and open to everyone. GPL licenses are often used by developers who believe in the principles of free software and want to ensure that their software remains accessible to all, rather than being locked away behind proprietary licenses.
In summary, GPL licenses provide a legal framework for software developers to release their software to the public for free. They allow users to access, use, and modify the software, ensuring that the software remains free and open to all. This is why software released under a GPL license can be free.
This means that WordPress will remain free for users to use forever. Bonus: Almost all software written to work with WordPress has to comply with the same licence, there are exceptions and it gets a little complicated. In principle though, when you see a software app that is designed to be a WordPress plugin it will also be released under a GPL licence, however the developers may ask you to pay a licence fee. This will not be for the software but for support, an update service and for some of the assets (images, logos etc).
Disclaimer: I am not a lawyer, so please do your own research before using licenced software.