I've always powered down machine to change out PS/2 peripherals. Is it necessary?
cite from wikipedia
PS/2 ports are designed to connect the digital I/O lines of the microcontroller in the external device directly to the digital lines of the microcontroller on the motherboard. They are not designed to be hot swappable. Hot swapping PS/2 devices usually does not cause damage due to the fact that more modern microcontrollers tend to have more robust I/O lines built into them which are harder to damage than those of older controllers; however, hot swapping can still potentially cause damage on older machines, or machines with less robust port implementations.
If they are hotswapped, the devices must be similar enough that the driver running on the host system recognizes, and can be used with, the new device. Otherwise, the new device will not function properly. While this is seldom an issue with standard keyboard devices, the host system rarely recognizes the new device attached to the PS/2 mouse port. In practice most keyboards can be hotswapped but this should be avoided.
I worked as a computer technician for about 20 years and I can tell you that while damage is extremely rare, it does, on occasion, happen. In all that time I had to fix about 50 motherboards, there is a resistor that gets burnt out and you have to replace it. Combined that with the fact that all modern motherboards use surface mount resistors, and this can be a major pain. I highly recommend switching to a USB keyboard/mouse if you haven't already.
I have actually blown the keyboard bios by plugging in a ps/2 keyboard while powered on. Yes, it was an older machine and I had to use USB keyboards from then on. Since then I've accidentally done it on occasion with other computers with no apparent harm. A couple of weeks ago (on a machine made around 2010) I did it and smelled something burning for a short time but everything still worked. If I were you I would avoid doing it all together.
I'm unclear whether there is a possibility of hardware damage (I've never done any damage, and it's just a serial protocol, so I THINK it's safe hardware wise).
The problem that I've found is that when hot-swapping PS/2 devices, I often lose control. That is, I take one keyboard out, put the new one in, and it won't work until I reboot the device. I'm unclear whether this is an interface level problem (something gets out of sync in the protocol, or a resettable fuse trips somewhere), or whether it's a driver level problem (lost comms mid-packet and never re-syncs), but I know that swapping PS/2 keyboards is a very hit-or-miss proposition.
I don't want to answer definitively, as I'm not a hardware expert, but I've swapped PS/2 mice and keyboards hundreds of times with the power on and never had a problem. One thing you may notice is that any custom settings for the keyboard may get reset; for instance, if you've increased the key repeat rate in the O/S settings, it will probably revert to the default.