Yes you can use PIC16F877A as a microcntroller. You’ll have to make some small modification for this project to work, like changing LAT register to PORT, removing the ANSELx with appropriate configuration
PIC16F877A does not have ANSEL registers. It will give you error messages if you use ANSELC = 0 or ANSELB=0. You can use ADCON1 instead if you want to configure these pins as digital pins as you can’t connect a keypad or relay to an analog input.