According to this post on the Steam Community forums brahmin increase the productivity of the settlement.
The game doesn't tell you what purpose the brahmins serve when they initially start spawning in your settlements.
However, once you randomly start running into the wastelanders on the road who want to sell you one, you can find out in their dialogue options.
They state that having a brahmin will increase the productivity of the settlement it is located in.
As well, as stated in the game's help menu, increasing the happiness of a settlement results in an increase to its productivity, apart from preventing its revolt.
So, my guess is that once you naturally increase a settlement's happiness to a certain level (I don't know the cut-off point), and therefore increase its productivity, a brahmin will spawn, as the concepts of "happiness," "productivity," and "brahmins" are interconnected.
I have only bought one brahmin so far, but I have six of them in my various settlements.
gaming.stackexchange.com/users/131280/KyleCrowley
They can be used to carry caravans around and can be killed for their meat as said here .
They can also be used to see dialogue actions and seemingly help boost productivity as well as said here :
"The game doesn't tell you what purpose the brahmins serve when they initially start spawning in your settlements.
However, once you randomly start running into the wastelanders on the road who want to sell you one, you can find out in their dialogue options.
They state that having a brahmin will increase the productivity of the settlement it is located in."
(This quote plus the link comes from @SlashTag)
gaming.stackexchange.com/users/100298/Anthony Pham
First of all I'm pretty sure Brahmin don't just spawn in your settlements, there is an NPC walking around selling Brahmin for 100 caps, and this person can usually be found anywhere between Sanctuary, Starlight Drive-in and Abernathy Farm.
I bought a brahmin off her and had to choose which settlement to send it to.
I chose Starlight Drive-in and sure enough my Brahmin was there when I showed up
so I built it a feeding tub.
I don't believe it's wise to buy brahmin for slaughtering purposes
, I know they provide meat and leather but it isn't worth 100 caps a head.
I do believe that brahmins produce fertilizer (shows up in 'junk' in your workbench).
Also, contrary to what many believe, you do not need brahmin to establish supply lines, I think you only need Local Leader perk (level 1) to do that, and supply line brahmin spawn automatically.
gaming.stackexchange.com/users/126315/PaulG
Brahmin is way more important than you thought.
As we know that the best way to get rich is selling purified water.
But the problem of selling water is purified water is heavy.
So here is another way to get rich:1.
Feed as many as possible Brahmins2.
Brahmin will produce fertilizer (in your workshop)3.
Use fertilizer (and plastic) to make Jet4.
Selling Jet Jet's weight is only 0.1 and it's expensive than water.
Better to use these 2 ways together, so that you can use purified water to exchange plastic.
gaming.stackexchange.com/users/218691/Alex Yang
I believe they also give your settlements Brahmin meat in the Workshop inventory.
gaming.stackexchange.com/users/90686/Scotty McDowell
After enough settlers and food troughs they will start coming in and killing them is only hurting you.
Get as many as you can for they add to happiness and productivity.
As well as they give you fertilizer which you can use to make ammo and jet which can be sold to make a load of caps.
gaming.stackexchange.com/users/152782/user152782
I was working in my settlements and found my first Brahmin in Starlight Drive In. After some research on the internet, I found a way to keep it in one spot using the feeding bathtub, but still, WHY do I keep it? Nobody on the internet seems to have the real answer. Does it add food? Does it makes people happy?  Basically, what is the use of Brahmins in my settlements?
What is the use of Brahmins in settlements?
gaming.stackexchange.com
<fallout-4>
gaming.stackexchange.com/questions/245670
gaming.stackexchange.com/users/131134/KeineMaster
Geta s many as you can. Brahmin increase the productivity of the settlement. They can be used to carry caravans around and will produce fertilizer.  Brahmins offer some benefits in settlements, such as producing fertilizers.
The community lists the benefits of Brahmins.