It *looks* like the plane was very close to the bridge, but anyone who has watched planes take off and land knows that the angle of the viewer makes a big difference. It's unlikely the plane was at an unsafe distance from the bridge.
As to why the plane seemed to take that particular flight path, I think sometimes UA pilots treat their customers to a "Bay tour" on days with good visibility. I don't know the details and I've never been on one, but it's been mentioned before in this forum.