There are three categories of people who are free from doing Mitzvas:
- Cheresh - a deaf-mute
- Shoteh - a mentally incompetent person
- Kattan - a child.
How do we know that they aren't liable for doing biblical mitzvos?
This is a somewhat complex subject. For now, I can supply only a partial answer regarding the Cheresh (deaf - mute) from this interesting article.
The original discussion seems to emanate from the first mishnah in Tractate Beitza. However, the article claims that the Chatam Sofer on Even HaEzer 2:2 posits that it is a Halacha l’Moshe Misinai. I don't have access to this source to research further what he says.
I am assuming that since the Talmud equated cheresh with shoteh and katan, that these other 2 fall under the same category, but I may be wrong. If you read Rash"i's explanation in Beitzah, he explains why the deaf are equated with the minor and imbecile. The article that I linked to focuses more on how the status of "cheresh" has probably changed, so while interesting, the majority of it doesn't address your question. But the beginning, listing the sources, probably does.
here's a relevant source (chovos halevavos shaar bechina ch.5)
It is through the understanding that we realize the Creator's wisdom, power and mercy, of which the universe provides clear evidence. It is the understanding which shows us that we ought to serve Him, because service is rightly due to Him, and because of His beneficence, bestowed upon all universally and on each one specifically. Through the understanding we are confirmed in our faith in the truth of the Book of G-d's Law given to Moses, His prophet, peace be upon him. Because of a human being's faculty of reason and perception, he is an accountable creature whom his Creator will hold to a strict reckoning. A person who has lost his understanding, loses all the excellencies of a human being and is exempt from the mitzvot (precepts), and reward and punishment.
the cheresh, shoteh, and katan are below the requisite amount of understanding to be liable for mitzvot as the talmud says in Chagiga 2b "just as the shoteh and katan lack understanding, so Cheresh [means] one that lacks understanding".
hence this is derived from reason.