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.
On a narrowboat or canal boat, the gunwale is synonymous with the side deck - a narrow ledge running the full length of the sides of the boat allowing a person to (cautiously) walk along the side of the cabin, generally with the aid of a handrail mounted on the roof.