This quotation has been credited to Mark Twain, William Watson Purkey and Satchel Paige. Regardless of who the real author of this piece is, it has become a popular piece of pop culture…

After some research it would appear that Mark Twain was too cynical and pessimistic to write such an optimistic piece.

William Watson Purkey is credited with writing:
Dance like nobody’s watching;
Love like you’ve never been hurt;
Sing like nobody’s listening;
Live like it’s heaven on earth.

Satchel Paige, baseball player is credited with adding the line:
Work like you don’t need the money;

Richard Leigh and Susanna Clark wrote a country music song in 1987 ‘Come From the Heart’ which includes the lyrics:
You’ve got to sing like you don’t need the money,
Love like you’ll never get hurt.
You’ve got to dance like nobody’s watchin’.