  We report results of a search for an isotropic gravitational-wave background
(GWB) using data from Advanced LIGO's and Advanced Virgo's third observing run
(O3) combined with upper limits from the earlier O1 and O2 runs. Unlike in
previous observing runs in the advanced detector era, we include Virgo in the
search for the GWB. The results are consistent with uncorrelated noise, and
therefore we place upper limits on the strength of the GWB. We find that the
dimensionless energy density $\Omega_{\rm GW}\leq 5.8\times 10^{-9}$ at the 95%
credible level for a flat (frequency-independent) GWB, using a prior which is
uniform in the log of the strength of the GWB, with 99% of the sensitivity
coming from the band 20-76.6 Hz; $\leq 3.4 \times 10^{-9}$ at 25 Hz for a
power-law GWB with a spectral index of 2/3 (consistent with expectations for
compact binary coalescences), in the band 20-90.6 Hz; and $\leq 3.9 \times
10^{-10}$ at 25 Hz for a spectral index of 3, in the band 20-291.6 Hz. These
upper limits improve over our previous results by a factor of 6.0 for a flat
GWB. We also search for a GWB arising from scalar and vector modes, which are
predicted by alternative theories of gravity; we place upper limits on the
strength of GWBs with these polarizations. We demonstrate that there is no
evidence of correlated noise of magnetic origin by performing a Bayesian
analysis that allows for the presence of both a GWB and an effective magnetic
background arising from geophysical Schumann resonances. We compare our upper
limits to a fiducial model for the GWB from the merger of compact binaries.
Finally, we combine our results with observations of individual mergers andshow
that, at design sensitivity, this joint approach may yield stronger constraints
on the merger rate of binary black holes at $z \lesssim 2$ than can be achieved
with individually resolved mergers alone. [abridged]
