What was the part that failed? The actual speedo in the cluster, the cable or the drive unit on the front axle?
If it was the drive unit on the axle that is usually caused by the dealer's assembly person forcing it when assembling the front wheel of the bike.
If it was the cable that can be due to either a bad cable or one that was not lubed properly when it was made.
If it was the actual speedo that could be any number of things, but still mainly a defect.
I am betting one of two things was wrong: bad/damaged drive unit, or the cable wasn't tightened properly at the cluster end.
Also, did you notice anything odd before it failed? Twitching needle, low indicated speed, etc?