What the hell is wrong with some people

Just yesterday I was walking home with my headphones on and this grown man kept tapping me and shaking my shoulder. He was saying I dropped something but I knew I didn't so I was ignoring and kept walking. He wouldn't stop touching me so I took my headphones off and turned where he crossed the road and yelled that I dropped something there. I knew I didn't drop anything but I was too afraid of him to just keep walking or tell him to piss off. So I crossed the road and pretended to look just for him to yell "Just joking!" And walked off with his friend laughing. Genuinely what did he gain from that and why the hell did he think it was ok to just touch a stranger for the sake of his prank.