In many contries, if they send you a check, even in error, you are allowed to cash it if you choose. I recommend consulting a lawyer, and keeping it in a seperate account for a while before spending. Local laws vary widely, some jurisdicitions will disagree. Consider local and national laws as they may appy. Ianal.
Regardless, it wouldn't have been right to keep the money. Especially since doing so probably would have caused problems for the person who made the misrouted payment.
I've actually never heard a story end that way. Pretty much all of them involve the bank convincing a court that a reasonable person would have recognized the error, and therefore you need to pay up.