Here's some info on the etymology of the word "baka."

According to some sources, the kanji for "horse" and "deer" are assigned to represent "baka" only phonetically. In this theory, "baka" was derived from the Sanskrit "moha" (meaning a person lacking knowledge). It was part of slang used by monks which came into general usage.

There is another theory, which concerns a Chinese Emperor and his power-hungry chief retainer. Since the Emperor was a little slow, the chief retainer had most of the power. One day, the retainer brought a deer in front of the Emperor and asked him what it was. The Emperor answered, "It's a deer, of course." The chief retainer said that it was a horse, not a deer. The chief retainer then asked all the other retainers in the room what it was. The retainers who were loyal to the Emperor answered that it was a deer, while those loyal to the chief retainer said it was a horse. The chief retainer said to the Emperor, "I assure you that this is in fact a horse, and all those retainers who say that it is a deer are lying to you." The Emperor believed him, and had all the retainers who said that it was a deer executed.

On the other hand, the Chinese don't use the word "baka," so this story might not be true.