Balloons retain a static electric charge due to the insulating properties of rubber. This material has a high electron affinity (likelihood of gaining electrons) relative to hair, so when you rub a balloon against your head, electrons easily come off your hair and build up on the surface of the balloon, and it acquires a negative static charge.
Rubber is an electrical insulator, meaning that electrons cannot move through it easily. The air around the balloons is also an insulator, so the negative charge remains on the balloon’s surface. However, if you touch the balloon with an electrical conductor, such as a metal ruler, the charge rapidly dissipates.