too long

$profile = JFactory::getUser($this->_user_id);
$userDetails = JUserHelper::getProfile($this->_user_id);
$profile->details = isset($userDetails->profile) ? $userDetails->profile : array();

I'd like to know the difference between the two function JFactory::getUser() and JUserHelper::getProfile().

And what do those 3 lines of code do?

An informative answer will be highly appreciated. Thank you!

While JFactory::getUser() method, returns the global JUser object (from where you can access the JUser methods, the JUserHelper::getProfile() returns the integer for user id. From here, it's your decision to choose what you need in your specific case - if just the use id integer or the JUser object.

$profile->details will not be set as it is not a property of the JUser object. This most certainly will throw you a PHP notice.