It was originally a piloting term that got borrowed by parents. When pilots aren’t allowed to fly for some reason—including bad behavior—they are said to be “grounded” (since they are stuck on the ground). Since this is similar to punishing a child by keeping them in one place and not letting them go where they want, the term got applied in that context as well (originally as slang, but then it stuck).