Why do vaccines cause your arm to hurt?
The goal of the vaccine is to provoke an immune response, therefore some degree of inflammation is expected in order for the vaccine to work. As swbarnes2 says, vaccines contain adjuvants, pro-inflammatory molecules that produces local inflammation and recruits immune cells to the site of the inoculation.

Since you get the shot intramuscularily, intradermally or subcutaneously, it is local, and the inflammation does not spread. The reason why your whole arm seems to hurt (rather than the place where the vaccine was deposited) is, I think, that where you got your shot, you have not many pain receptors, and your brain is not able to determine the pain source very exactly.