…often said with the unspoken implication that it’s a good reason, planned by a higher power, and that you should just meekly accept things and shut up.
Everything happens as the result of an infinite number of things that happened beforehand and led inevitably to this thing happening now. Free will is a lie.
Super closely related is the "god works in mysterious ways" apology often used as the response if you ask what that reason was. It's bizarre that the people saying that quote are so insistent that everything happens for a reason even though they cannot answer what that reason might be (and usually get really uncomfortable if you press for an answer).