Vitamin D acts in a way which to me is counterintuitive. It functionally supplemets Parathormone. It in the intestinal tract steps up calcium absorption by altering nuclear gene expression and also prevents calcium excretion in kidneys. All of this is understandable. But it also, like parathormone, steps up osteoclast action in bone (actually steps up both osteoclast and osteoblast, but the osteoclast action is increased more to result in net bone resorption). This means that Vitamin D increases blood calcium level by increasing bone resorption.
Then how does Vitamin D help in improving bone density, bone strength and prevent rickets or osteoporosis? All of these would require bone deposition rather than resorption.