Why is のこと used in the sentence below?
Or more specifically, what is the difference between V-ときです and V-ときのことです?
むかし、むかし、桶屋で働く若者が桶にする竹を切っていた時のことです。
桶にする竹を切っていた時
Would refer to the time he cut the bamboo.
桶にする竹を切っていた時のこと
Refers to the things (こと) that happened during the time he cut the bamboo.
The former one pays attention to the time, while the latter one pays attention to the event.
This is going to help a lot in answering your question: What is the こと in sentences such as あなたのことが好きだ?.
The selected answer explains how こと or 事【こと】 can be used in a few significantly different ways:
to encompass the things around an object/concept (i.e. "about"), like your sentence does --
時のこと (the event... / the thing(s) that happened when...)
to simply mean "thing"
to add a layer of indirectness