The passage of the bill, which appeared dead just weeks ago, caps a Democratic effort to deliver on major components of President Biden’s agenda.