I had never paid attention to the Montana-Idaho border, assuming that the squiggly line included a river or two - but it's just a line following the crests of mountains.
The separation between Idaho and Montana begins where the Continental Divide intersects the 111th meridian. It then follows the Continental Divide to the point where it intersects the Bitterroot Mountains. Here the crests of the Bitterroot Mountains becomes the boundary up to the Clark Fork River, where a straight line due north completes the border.The history behind this border is discussed here (politics and maybe money involved).
Image via Vivid Maps.