A system that is intermittently unresponsive to the trackpad and keyboard might have a hardware issue or it may be that the problem is that the system is hitting 100% CPU and/or 100% disk resource usage so cannot respond to user input in a timely manner.
I would start by monitoring the system using Windows' Task Manager, which you can start by right clicking the Windows icon on the task bar and choosing "Task Manager", or by pressing Ctrl+Shift+Esc. The Performance tab is probably the most useful tab to start with, as that graphs key performance parameters over time. If something is maxing out, you can then use the Processes tab to find out what is maxing out the system; you can click on the column of whatever is maxing out to sort that with the most usage at the top.
It is also worth running the HP Diagnostics on your system to see whether that identifies a possible hardware issue.
I maintain my original suspicion that you are suffering a disk and/or CPU resource exhaustion issue, rather than a hardware failure. A hardware failure is possible, but for two input peripherals to be intermittently unresponsive would be unusual.
As well as monitoring the situation in Task Manager, can you try the system with an external keyboard and mouse (or other pointing device). If you experience no problems with that setup, it might be an issue with your notebook's hardware, but if the issue remains that suggests you are suffering a disk and/or CPU resource issue.
If you truly believe the evidence so far indicates hardware failure even though the diagnostics pass, you could discuss the situation with HP - but they might be loath to authorise warranty service on the evidence so far. It isn't clear what component(s) of the system should be replaced if this is a hardware issue. I doubt they will just replace the keyboard, trackpad and system board but maybe they will prove me wrong.
Be alert for scammers posting fake support phone numbers and/or email addresses on the community. If you think you have received a fake HP Support message, please report it to us by clicking on "Flag Post".