This joke is kind of funny because in ancient times, it was not only their feet that were bare when they slept.
An idiot has a dream that he has trodden on a nail, so he wakes up and bandages his foot. His friend asks what he’s doing, so the idiot explains about his dream. Then the idiot points out that his friend also slept barefoot. He comments, “We’re such morons — I can’t believe you’ve been sleeping barefoot.”
Like the idiot’s foot, this joke is kind of ‘lame!’