Hello;
Allow me to welcome you to the HP forums!
It's generally a BAD idea to replace the preinstalled OS on a prebuilt PC with a different version. This is because the preinstalled PC comes with the proper OEM drivers for the hardware included on the motherboard and with the PC.
While there's nothing stopping you from installing Win8.1 on this PC, there are no HP Win8x drivers for it.
And, although the Win10 drivers SHOULD work, there is no guarantee that they will. You might have to end up installing them in Compatiblity mode to get them to work, and even then, they might not.
Good Luck