It’s tempting to believe that all laws are noble and rational and based on logic. It’s also deceptive and delusional. Quite a few laws are just reflections of the collective prejudice of the majority (call it moral conviction if that goes down more easily). This prejudice can be against anything—blacks, women, homosexuals, scientists—whatever the majority takes a dislike to can often be codified into law. In that sense, laws are sometimes just legislated mob mentality. 
There doesn't seem to be any morally consistent and reasonable reason for forbidding sex with animals, when there is practically no restriction against killing them (let's ignore, for the moment, endangered animals and the like, and restrict our discussion to commonly eaten animals such as goats or cows or pigs). Also, murder receives greater punishment than rape (in case of human victims), so even that doesn't qualify as an argument.
As a few other answers have noted, there are a reasons for why there is a cultural bias against having sex with animals and a large cultural bias in favour of eating animals.
Why is sex with animals illegal?
Because the law was once made due to some cultural norm and now no one is lobbying for the issue. This is also true for other laws, such as those against homosexuality that are extant in many countries. It is still not a big enough issue for a candidate to take up, and taking it up is likely to call loss of votes rather than victory. The bestiality lobby isn't big enough or strong enough.
Note that the same applies to eating non-vegetarian food. It is legal because the vegetarian lobby isn't influential enough (yet) and no candidate is taking it up as an issue. In Madhya Pradesh (a state [province] in India), cow slaughter is now illegal (it is punishable with up to 7 years in prison), simply because they could get enough people to support this legislation. 
 Note that repealing such laws requires changing the mind of the majority, as was done in the case of racist legislation. It can't be done simply by appealing to logic or ethics.