Many medicines taste bitter because they contain alkaloid (baselike) compounds. Quinine, caffeine, and the antihistamines are familiar examples.
Wikipedia foundation.