In this story Zane is getting picked on for having an imagination and so Dan tells Zane a story about an old purple dinosaur friend of his and how having an imagination is a good thing.
Dan then tells the story and they see the flashback on how it all started.
I know what your thinking, why are you doing a Barney story? Well I grew up with it and even though I'm not a kid anymore I still love Barney for everything he taught me while watching his show and movies growing up.