Use of PID to get the required RPM.

what's wrong in this?

You tell us. What does the program do?

How did you choose Kp and Kd and why do you think those values should work properly?

Put some print statements in the program to make sure that the error term and the PID-derived corrections are in the correct direction and are reasonable values.

Finally, it is a mistake to repeatedly use attachInterrupt() and detachInterrupt(). There is no need at all to use detachInterrupt().