There are two pieces to this question:
a) How does bone resorption (movement of Ca/Phos out of bone into the blood) result in net improvement in bone structure?
Bones are constantly remodeling, primarily in response to mechanical stressors. Although you clearly already realize this, I will make it explicit: osteoblasts are the cells that create new bone; osteoclasts break down (resorb) bone.
Quoting Harrison’s Internal Medicine1:
Radioisotope studies indicate that as much as 18% of the total skeletal calcium is deposited and removed each year. Thus, bone is an active metabolizing tissue.…The cycle of bone resorption and formation is a highly orchestrated process carried out by the basic multicellular unit, which is composed of a group of osteoclasts and osteoblasts
Bone mineral density (BMD) can not be equated with bone quality. (This is the difference between osteoporosis – deficient bone density – and rickets – poor bone architecture.) Thus, vitamin D’s stimulation of both osteoblast and osteoclast activity is beneficial to bone structure.
b) How does vitamin D lead to overall increased bone density?
In addition to the effects above, you mentioned that vitamin D increases serum calcium by several mechanisms. This is true. Both this increased serum calcium as well as the direct effects of Vitamin D on the parathyroid gland suppress PTH production.* As PTH has powerful actions to increase bone resorption by mobilizing calcium and phosphorus to move from the bone into the blood, the suppression on its excretion applied both directly and indirectly by Vitamin D results in a net increase in bone density.
Thus, both by its effects on bone quality and quantity, vitamin D is a net boon for the bones.
*Parathyroid hormone, a.k.a. parathormone. There is a paradox here, because drugs such as teriparatide (a.k.a. Forteo, recombinant PTH) are anabolic for bone and are used to treat osteoporosis. Although the mechanism is unresolved, intermittent administration (as in the case of drug treatment) increases BMD while chronic sustained elevations decrease BMD.2
References
1. Bringhurst F, Demay M.B., Krane S.M., Kronenberg H.M. (2012). Chapter 352. Bone and Mineral Metabolism in Health and Disease. In Longo D.L., Fauci A.S., Kasper D.L., Hauser S.L., Jameson J, Loscalzo J (Eds), Harrison's Principles of Internal Medicine, 18e.
2. Rosen CJ. The cellular and clinical parameters of anabolic therapy for osteoporosis. Crit Rev Eukaryot Gene Expr. 2003;13(1):25.