From here:
If you delve into the lore of Dark Souls (which is filled out by fans of the series), it's widely believed that the sun is a deity in the Dark Souls universe and it's even possible to cause the sun to vanish by carrying out certain actions in the original game. In Dark Souls 2 however, developers From Software embraced the love of the sun even more by adding multiple locations throughout the adventure that had gorgeous views of the lovely shiny object. Every single message you'll read here will either say Praise the Sun or Gorgeous View Ahead. It is a rite of passage for anyone playing Dark Souls to proclaim their love of the sun wherever necessary. It's just a thing that must be done.
Lore-wise, the term refers to the gesture rewarded to members of the Warriors of Sunlight covenant, who use a gesture with the same name to express themselves.
tl;dr: It's just a thing you do. If you play Dark Souls, you must Praise the Sun.
It's like the Do a Barrel Roll! meme from Star Fox, but for Dark Souls.
EDIT: As noted in the comments, the popularity of "Praise the Sun!" can be at least partly attributed to Solaire of Astora and his intense praising of the sun:
"Oh, hello there. I will stay behind, to gaze at the sun.
The sun is a wondrous body. Like a magnificent father!
If only I could be so grossly incandescent!"