Anyway, which is the reason to access a variable through a member function if you can get the variable directly anyway? Or is there any case where you can't?
 
The code you quoted is just trivial example of "how to use shared_from_this()", not "why to use it".
If you want to realise *why* such a feature can be useful, look, for instance, at ASIO examples:
http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/tutorial/tutdaytime3.html
Actually, there're lots of cases where you might want to make shared_ptr of "this" inside a member function.