Permanent damage to PIC16F877A
I assume from your description that the MCU is being damaged, and replacing the MCU solves the problem. 

It looks to me like a layout issue, which is not captured in your schematic. 

Without further information, I would suggest adding series resistors on the CLOCK and DATA lines, perhaps around 1K (depending on how high your clock frequency happens to be). The 74HC164s may be pulling those lines below ground when the high segment currents switch. 

Rather than blindly doing that, you can put an oscilloscope on those lines and see if indeed there are transients that exceed the power supply limits in either direction. Such transients can cause latchup of the MCU and destruction from power supply current can ensue. 



Edit- 

Yes, your layout is pretty horrific, in particular the power connections are thin, long and meandering so they have a lot of inductance. A 2-layer or 4-layer board would be much better, but of course that costs money.