So, how do exactly do you befriend your bones? Ideally, you develop bone-healthy habits as young as possible, but there are steps you can take at any age. (This is one of the many cases of “the earlier the better” but “it’s never too late to try.”)
We actively build bone until our 20s. Specifically, we reach our peak bone mass in our spines between the ages of 21-27; for our hips, we reach peak bone mass between ages 19-24. This the “modeling” phase, because your bones are kind of being gradually sculpted to their eventual final adult size and shape as you grow. But you are also laying down bone in a manner that can make them more dense, or less dense. This is a “critical window” that kind of sets you up for the rest of your life. If you have bone-healthy habits during these years, your bone will be better able to withstand some of the natural erosion that comes with age, and while your bones may become less dense, it may never progress to osteoporosis and the fractures that can come with it.
After age 24, the bones begin a slow decline (this decline steepens for about 5 years post-menopause in women, before resuming the more gentle downward trajectory). This is the “remodeling” phase, where your bone is constantly being nibbled away by one type of cell (osteoclasts) and rebuilt by another type (osteoblasts). In an ideal world, the osteoblasts rebuild 100% of what the osteoclasts take away, but that doesn’t quite happen. 
Why do the osteoblasts nibble? One big reason is that our bodies need to maintain a steady level of calcium in our blood (this has to do with pH and other things). If we don’t have enough from our diet, our bodies will take it from our bones. Yes, our bones are important, but blood calcium levels are more important to our day-to-day survival.
Basically, it comes down to three things:

  • Nutrition. Get adequate calcium and vitamin D. Get adequate but not excessive protein. Calcium-rich foods include dairy products, sardines or canned salmon (because you eat the bones), tofu made with calcium, calcium-fortified foods and some dark leafy greens. Kale, collard and mustard greens are good (so is broccoli), but spinach contains oxalic acid, which makes its calcium unavailable to us (it does not affect absorption of calcium from other foods you eat during the same meal, however). If you take supplements, calcium carbonate is less expensive and just fine for most people (unless you know you have low stomach acid). Calcium citrate costs more, but tends to be better for older adults (who generally do have lower stomach acid).
  • Exercise. Weight-bearing exercise puts stress on bones that signals our bone-building cells that “hey, you need to build us up!” Unfortunately, this becomes less true as we age, simply because we have fewer of the cells that respond to those signals. However, older adults still benefit from weight-bearing exercise for muscle maintenance. Exercises that help maintain balance, such as Tai Chi, can also help avoid falls, which is a major benefit. Contrary to what some people say, you almost never break a hip and then fall. You fall (often to the side) and then break a hip. So avoid falls!
  • Avoiding “bad to the bone” behaviors. These include smoking, excessive alcohol use (as well as being sedentary and eating a nutrient-poor diet).

All of these factors become more important if you have a unfortunate genetic hand when it comes to your bones. Like it or not, 70 percent of our bone destiny is due to heredity. Women are at greater risk than men, especially white and Asian women. If you have a family history of osteoporosis, you are at greater risk, too.
So, eat a healthy diet with enough calcium and vitamin D, exercise regularly, and include exercises to improve balance in your routine. If you know or suspect you are at particularly high risk of low bone density or osteoporosis, talk to your doctor. If you have any specific questions, feel free to ask them in the comments. I’m not an expert, but there was a lot of good material in the lecture I mentioned, plus we’ve been covering calcium, vitamin D and other bone-related nutrients in my Nutrition & Metabolism class.