So I opened it up and saw this. The heatsink was completely clogged with dust. I cleaned it off with some Q-tips and WD-40 and the rattling noises stopped, and the Macbook runs a lot cooler now. The fan still gets loud if I'm playing youtube videos but it's a 100% improvement. Moral of the story: clean your fans at least once every 8 years!