'To be at wits' end' is, literally, to run out of ideas. To be very worried or upset because you have tried every possible way to solve a problem but cannot do it. Completely puzzled, perplexed, not knowing what to do. I've tried every possible source without success, now I'm at my wit's end.
Note that the apostrophe is placed after the s of wits (meaning abilities), not after wit (one's humor or intelligence).
The phrase comes from the Bible, Psalms 107:27 (King James Version): "They reel to and fro, and stagger like a drunken man, and are at their wits' end." The original Hebrew of the Bible says, "חָ֝כְמָתָ֗ם תִּתְבַּלָּֽע׃ " which is transliterated as "chachematam titballa." This is translated as "their wits' end."
The phrase has also been used when a diagnosis for an illness cannot seem to be found for a person.'
It's most frequent use seems to be by parents. Mothers and fathers have said "I am at my wits' end" when it comes to thinking of things to keep children busy.