If this button is greyed out so you can’t set keyframes when an object is selected….
then save your file and gradually go through deleting all objects in the scene until it goes back to normal.
When you have worked out which object being present has caused this then note this down and revert back to your saved file and just delete the one offending object that was causing this problem and continue working.