Mental Floss has a fascinating answer to this question. The cotton ball was originally placed there to prevent tablets from breaking during transport, but that particular problem was solved in the 1980s with coated tablets. So,
But after decades of opening aspirin bottles and finding the fluffy filling, consumers were conditioned to expect it, even believing that it was a good way to tell if the package had been tampered with, or that it helped keep the pills “potent.” Consumer beliefs like these—and tradition—were the main reasons Bayer kept cotton in their bottles for so long, and likely play a part in why some brands still include it today.
. . .
But here’s another secret: Not only is the cotton in some bottles totally unnecessary, it probably isn’t even cotton. According to the Drug Information & Side Effects Database, most of the plugs are made from rayon or polyester.