Wale is the same word as the skin injury, a weal, which, too, forms a ridge. Originally the gunwale was the "Gun ridge" on a sailing warship. This represented the strengthening wale or structural band added to the design of the ship, at and above the level of a gun deck. It was designed to accommodate the stresses imposed by the use of artillery.
In wooden boats, the gunwale remained, mounted inboard of the sheer strake, regardless of the use of gunnery. In modern boats, it is the top edge of the side where there is usually some form of stiffening.