The minerals that are responsible for hard water deposits tend to precipitate out of solution (water) when subjected to high heat for a long period of time. This is the exact condition found in a typical tank-type water heater. Those conditions do not exist in a tankless water heater, so mineral build-up is minimized. Further, there is no low-pressure water storage in a tankless water heater, so most minerals, sediments, and other debris simply passes through the unit with the water flow rather than accumulating.
overall, tankless water heaters tend to handle hard water minerals and sedimentation very well. If your water is extremely hard, softening the water would generally be recommended not only for your water heater, but to prevent other plumbing problems.