The dependence of the superconducting properties of YBa2Cu3O6+y on the oxygen content y is discussed in terms of a two-phase model in which it is assumed that the optimal hole concentration, p(opt) = 0.25 per CuO2 unit, is a local condition and that the average hole concentration p smaller than p(opt) results in phase separation into superconducting and insulating phases. For y = 1, p = p(opt) is satisfied everywhere in the CuO2 plane and the material is a homogeneous bulk superconductor. As p decreases with decreasing y, the fraction of the insulating phase increases and superconductivity takes place through a 2D percolative network. Macroscopic superconductivity is lost when the insulating phase forms an infinite cluster. It is argued that the oxygen ions in the CuOy plane affect the superconducting properties not only by controlling p but also by modifying the hole distribution in the CuO2 plane through local structural changes and long-range Coulomb interaction. Explanations are given of the two-plateau structure in the T-c versus y curve and of the appearance of the seemingly homogeneous ''60 K phase'' at y similar to 0.5-0.6. The relevance of the two-phase model to other systems and the origin of the phase separation are also discussed.