Go to: https://www.microsoft.com/software-download/windows8

Once you have the ISO, create a bootable USB with Rufus and install. But remember: Windows 8.1 is no longer supported. If you need a stable, secure OS, move to Windows 10 or 11.

How to Safely Download Windows 8.1 ISO (64-Bit) – Official & Legal Methods