Most Microsoft operating system licenses (in fact, most Microsoft software licenses more generally) include what are called “downgrade rights”: the right to run any prior version of the product for which you are licensed, in lieu of the product you are actually licensed for. If you have an Enterprise or Volume license of Windows operating system license, your license is valid not only for the version you bought, but all predecessor versions. A Windows 10 Professional license is also valid for Windows 8.1 Professional, Windows 8 Professional, Windows 7 Professional, Windows Vista Professional, Windows XP Professional, Windows 2000 Professional, Windows NT 4.0 Workstation, and Windows NT 3.1 Workstation. I’m not sure about Windows Me, Windows 98, and Windows 95; I think those are predecessors of Windows XP Home, which is not a predecessor version of Windows 10 Professional; you may have to buy a Windows 10 Home license if you want to use Windows 95 legally.
Windows licenses distributed in the OEM or Retail licensing channels are sometimes restricted in their downgrade rights, and may not include all predecessor versions. You will have to check the specific license terms to learn its downgrade rights. However, all Volume and Enterprise licenses are downgradable without restriction. Converting an OEM or Retail license to a Volume license (by enrolling in Software Assurance) converts the license to volume licensing terms, including unlimited downgrade rights.
Microsoft will not necessarily provide you with the media or a license key for these prior versions (typically they only provide the prior two versions to customers through their normal distribution channels), but you have the legal right to use any version you want if you have a license with downgrade rights. But if you can obtain working installation media and working key for the version you have installed, your use of the product will be, in most cases, legal as long as you have a valid license for that version or any successor version of that product (and that license is not assigned to any other installation).