RE: what is the main difference
A very significant difference is that Microchip labels the PIC16F877 as a mature product and, as such, is not recommended for new designs. They recommend the PIC16F877A as a replacement.
Just a few other notable differences:
PIC16F877A flash writes are performed in 4-word blocks
PIC16F877A has a wider operating voltage range
PIC16F877A has a different programming specification
PIC16F877A has a different configuration bits layout
PIC16F877A has analog comparators
PIC16F877A's /MCLR difference:
From PIC16F87XA Data Sheet DS39582B:
"The behavior of the ESD protection on the MCLR pin
differs from previous devices of this family. Voltages
applied to the pin that exceed its specification can
result in both Resets and current consumption outside
of device specification during the Reset event. For this
reason, Microchip recommends that the MCLR pin no
longer be tied directly to VDD. The use of an RCR
network, as shown in Figure 14-5, is suggested."
For more details see the following appendix in PIC16F87XA Data Sheet (DS39582B):
APPENDIX C: CONVERSION CONSIDERATIONS
Considerations for converting from previous versions of devices to the ones listed in this data sheet are listed in Table C-1.