While making the BBC programme, which sees celebrities trace their family histories, the comedian found out that his great-great-grandfather was a street performer.
He would play a wind-up organ while his pet monkey collected money from passers-by.
Walliams said: “Well I was glad that there was some link, because obviously you are often thinking about what shaped you, why did you get drawn to certain things – being on stage, or trying to make people laugh, or writing stories, whatever it is.”
He added: “He seemed to be eternally optimistic – he was just winding up the organ, but said on a form he was a professional musician, which makes you think he might have played the violin in an orchestra.
“And to become part of the travelling community and become a showman, that’s quite something, because it’s a closed world as it’s passed on from generation to generation.”
Walliams also learnt about his great-grandfather having to be treated in a mental health hospital following his experiences in the First World War.
Well I was glad that there was some link, because obviously you are often thinking about what shaped you, why did you get drawn to certain things - being on stage, or trying to make people laugh, or writing stories, whatever it is
He said it is “a very sad story”, adding: “Although I think he was very well cared for later in life, it’s not something you would wish on anybody.
“I’m sure that there were many other men who had the same experience.”
Walliams’ episode of Who Do You Think You Are? airs on Monday October 19 at 9pm on BBC One.
Jodie Whittaker, Liz Carr and Ruth Jones also feature in the current series.