How does the law define “being of sound mind”?

You have probably seen TV shows, films and indeed possibly heard wills read out that refer to the term “being of sound mind.” But what does this term actually mean and how do people define it? What initially may seem like a simple question can be complicated by the...