Well, since no one else is responding, I'll at least keep the conversation going in the hopes that one of the "regulars" will see the thread. I don't live aboard, but that doesn't make me any less concerned about safety for my kids (7 and almost 5). How old is your grandkid? If less than 2, you'll have it somewhat easy in that the baby won't be super mobile yet. So, that means you can keep him/her in sight most of the time. Sure, he/she can crawl, but you'll pretty much always know where the baby is. Once they hit 2, though, things change a LOT. You're dealing with someone who will be fairly stable on their feet, and who will want to explore every nook and cranny. Baby proofing will be a must. On the plus side, though, much of baby proofing would be advantageous on a boat - you're ensuring that cabinets close and lock, that things like bug spray and motor oil are stored safely so they don't spill, etc. The bigger issue will be loose wired that are tucked behind something, or just hanging down - those are very tempting hand-holds, or teething toys.
One real advantage of having the baby/toddler aboard is that you get them used to the boat, and the boat's rules, from the start. No being on deck, or in the cockpit, without a life vest, especially until he/she can swim. We stretch this a bit, and when we're at the dock, our boys can come into the cockpit without their PFD's, but they can't go forward without one even at the dock. We had lifeline netting on our old boat, and I'll be ordering some of that for the next boat when we get it. The netting is NOT a substitute for good adult supervision, and you should never rely on it. But it sure is nice to know that it's there, because accidents happen in an instant, and always at the worst of times.
Now that the boys are getting older and getting better at swimming, and now that we're getting a bigger, more stable boat with a larger foredeck, we'll be letting them go forward when the boat is underway, but I'll be running jacklines and they will be clipped in. We have the Mustang life vests with the crotch strap for them, and they always wear it completely zipped/snapped. I'm leaning toward adding a mil-spec strap through the back of the life vest so that any forces from their fall are dissipated through the vest, rather than just a harness. I think that's less likely to result in broken/bruised ribs than a harness.
The big thing, as with any child in any space, is to ensure that the baby has room to play, explore, and roam, including off the boat. It's an important developmental time for the baby, and you want to be sure it is as rich as possible. But, realistically, the 40' boat is going to have something in the neighborhood of 300 or so square feet of living space, plus an 8x10 "patio" (cockpit), and a swingset/playground (the spinaker halyard, forestay, etc.) - that's as good or better than some apartments in big cities. So it CAN be done.