I first heard "baa ram ewe" from the sheep in Warcraft 2. If you click on the units repeatedly they'll start getting annoyed with you. The sheep say "baa ram ewe" when they get annoyed. I always thought it was a cute way of saying "god damn you", since they sound similar phonetically.

I was talking to my girlfriend, and for some reason said "baa ram ewe". Surprisingly, she laughed. I thought I had been making an obscure Warcraft 2 reference. I asked her about it, and it turns out a sheep in the movie Babe said "Baa ram ewe".

Since then I started wondering which came first. I just looked it up and found that Warcraft 2 and Babe were both released in 1995. So no easy answer from the release dates.

It's also possible that the two are unrelated: a friend suggested that "Baa ram ewe" was a statement in (un)common use before Babe OR Warcraft was released. Hence making both of them culture references. That sounds like the most likely origin to me.