The pepper plant evolved its fruits to be eaten by birds and disperse its seeds. Birds are not affected by capsaicin, the chemical compound that makes spicy peppers feel hot. Pepper plants don't even want mammals to eat them because pepper seeds aren’t resilient enough to handle our digestive system, but humans have actually liked the pain and have enjoyed the hot taste associated with peppers. Humans have consequently not only spread peppers globally but have even gone as far as breeding them to be spicier.
FYI, cayenne works well to keep squirrels out of bird seeds. Birds don't mind it but squirrels will avoid it.