This will be a quick run down through rooting and installing TWRP on the LG G3 D851 running Android 6.0 Marshmallow.
NOTE: This is only intended for the T-Mobile variant of the LG G3. The model number should be D851!
STEP 1: Download and install KingRoot App
To root this LG G3, we shall install KingRoot App and run it. You should grant it root access. This root process may be temporary. You may need to repeat the process every after reboot. Currently, there doesn't seem to be a permanent root procedure for the LG G3 running Marshmallow.
STEP 2: Install TWRP Manager
Download the TWRP Manager App and grant it root access when it opens. Select Install TWRP within the app. On Device name, type G3 and select LG G3 T-Mobile USA. Select Recovery Version to install and select the latest version that ends with the model number d851.img in it. Go ahead and select Install Recovery. Let the recovery download and install. This is however a temporary recovery to create space for the permanent one to be installed later.
STEP 3: Reboot into recovery
After TWRP is successfully installed, use the TWRP Manager app to boot into recovery. You should see the new recovery. Here I'd suggest you make a backup of your entire system using the backup option.
STEP 3: Boot into system
Right from recovery, boot into system. You should be prompted to install the Official TWRP App on root partition. Go ahead and install. After bootup you should see the new Official TWRP App installed. Open it and select TWRP FLASH, Select Device as LG G3 T-Mobile -- d851, choose latest recovery and flash it. This should permanently install TWRP.
After installing TWRP, you can be able to flash any custom rom i.e upgrade to any Android version available. To boot into TWRP manually, turn off the phone, hold the Volume Down and Power Button until the logo displays. Right after the logo shows, release the Power button and hold it again. Use the Volume Down button to select Yes and again select Yes on the next screen. The phone should open TWRP.