Seems you're having problems with HDD being too slow. You can confirm this by executing this command immediately after you notice the problem: grep "" /proc/pressure/* and checking the output. Most likely the /proc/pressure/io would have high numbers on the avg10= column.
I was recently traveling with an old laptop with similar specs: 8G RAM and a slow HDD. Modern apps often take a lot of RAM, so things quickly become very laggy. An ideal solution would be to increase RAM and buy an SSD. But I wouldn't be writing this answer just for this suggestion Advices below are battle-tested and improve system response significantly.
Swap is your friend. You want to make sure there's enough free RAM for file-system cache to reside in, because the way to speed-up file-related operations here is to make sure disk is accessed as little as possible. So first thing to do is to increase swappiness to 100. Create file below and reboot:
λ cat /etc/sysctl.d/99-sysctl.conf
vm.swappiness=100
You can check if it worked with sysctl vm.swappiness command.
The newer the kernel the better: every kernel release there are many improvements in various algorithms related to FS operations, allocations, SWAP, etc. Also it's important to note that Ubuntu enables MLRU which is a great recent algorithm for better choosing an unused memory to store to swap.
24.04 has 6.8.x kernel, which would've been fine enough, weren't it for the fact the next point will require at least 6.9.x kernel.
Askubuntu has instructions for how to install the most recent kernel here. Which version is the latest stable release you can see here. Important: once you install it, make sure cat /sys/kernel/mm/lru_gen/enabled is non-zero, because MLRU may or may not be enabled in that config, and it matters a lot for latency.
Compressed SWAP: this is the most important point. Whenever memory gets swapped-in or out, this takes precious IO, which you have very little to spare. So you want it to be compressed before it gets stored on disk.
For how this can be done you can refer to these instructions I wrote on Unix.SE. Here it's important to note that KVDO was only merged since 6.9 kernel, so you need to be running 6.9 or higher. There are out-of-tree drivers that older kernels, but running more recent kernel is just more useful.
Actually, you might also try sudo apt install linux-image-generic-hwe-24.04 to see if by any chance Canonical backported KVDO to older kernels. But I wouldn't count on it since KVDO isn't a typical usecase for HWE kernel.
P.S.: there's also debatable optimization of installing your whole system to BTRFS with compression enabled. I do that and compression does reduce IO. But whether it helps with the fact data may get fragmented with time, thus increasing latency, is an open question.