-- Would you like a piece of this exquisite chocolate cake? -- Why, of course!
The expression is much stronger than "yes" and indicates that the speaker is excited to do something that somebody else suggested. The word "why" makes the expression even more emphatic. You can also say "Why, yes!" (less strong).