I have a vinyl three rail fence that the goats can and have easily gone through. I added three strands of hot wire to keep my pig and horses from destroying the fence, and also keeping coyotes and racoons out of the fenced area. The goats ignore the wire.
I've found that for me, keeping them happy is all it takes to keep them around. We feed all our animals every evening and they are all there waiting for us at feed time. Once they get used to the feed, they can't wait for it.
Since horses are such pigs and they try to eat everyone elses food, we have closed off areas to keep them out. I cut a small opening into a wire filled gate that the goats can fit through, but not the pig or horses. They get fed in there now, and then they spend the night in there. They also hang out during the day in there too. I have two pastures, one if five acres, the other is 6 acres. They wonder out all over both pastures, but also come back to the barn multiple times during the day. We think that they consider it their home, but it's also where the water trough is. Even though there is a 3/4 acre pond, they seem to prefer drinking city water out of the trough. Same with the horses.
Another thing we've learned is that when we get a new goat, we lock it up for a week or so. We let it get used to the barn and the other animals, and when we let it out, it hangs out with the other animals.