Yes, wearing long underwear and clothes keeps you warmer inside a sleeping bag. Your clothes are another layer of insulation that keeps your natural heat close to your boy and prevents it from escaping.
However, there are some instances that wearing clothes inside your sleeping bag will not keep you warmer. Here are some:
When you wear too many layers of clothes or if you fill your bag with other stuff that you compress the insulation in the baffles of the sleeping bags, thereby reducing the amount of warm air it could trap.
When you wear ill-fitting clothing items like socks that are too tight that they cut the blood circulation off your feet and make them feel colder.
When you wear moist clothes and compromise the insulating power of your sleeping bag.
When you wear too many clothes or if you chose the wrong bag for your trip and it makes you break into sweat. The result would be like if you’d been wearing moist and damp clothes. If you become too hot inside your bag, you could unzip it a little instead of perspiring inside.
It is best to wear a fresh and dry base in your sleeping bag to keep it cleaner and to keep you warm in chilly nights. These clothes should fit well, better if these fit loosely, so as to not cut off circulation, and to help trap heat closer to your body.