Apple - Is there a problem with closing the lid of a MacBook Pro when using an external monitor?
Clamshell Mode
What you are describing when you operate your Mac laptop (Macbook/Pro/Air) is called closed clamshell mode or closed display mode.
In this Apple Support Article: Use your Mac notebook computer in closed-display mode with an external display it goes into detail on what the requirements are and how your Mac will function depending on the version of OS X you are running.
But basically, you can hook up an external mouse, keyboard and display and use it like a desktop. As far as what you can do with your Mac, pretty much anything you can do with it open, you can do with it closed
Ventilation
The vents on your Macbook are located in the rear and along the bottom - they are not obstructed when the lid is closed.
How heat gets dissipated is more determinant on where it's placed rather than if it's open or closed...
Where you use the system may affect fan behavior and heat as well. Using the computer on a soft surface like a couch, pillow, bed, or your lap can trap heat requiring higher fan activity. Using the computer on a hard flat surface like a table or desk allows for optimal radiation of heat.
The vents are located along the back, not under the keyboard:
Mac computers have air vents that allow heated air to exit. The vents are in the back of the computer on the MacBook, MacBook Air, MacBook Pro, and Mac Pro computers. iMac (Mid 2012 and later) models vent along the bottom edge of the computer. Make sure the vents remain unblocked to allow your computer to perform at its best.
There is also no need to continually monitor the temperature of your machine. The only time you need to do this is if you are having a problem like it's slowing down significantly or shutting down unexpectedly.
The System Management Controller (SMC) firmware on every Mac manages the thermal conditions of the computer regardless of the operating system.
Basically, if your Mac gets "too hot" it will automatically shut it down to protect itself. But before that happens, it will slow everything down to a crawl.
Source: Apple Support - Learn about the fans in your Mac
With some care it can be done safely. It depends by and large on what kind of loads you're placing on the MacBook when it's being used like this.
The MacBook Pro's ventilation operates optimally with the lid open. Closing the lid restricts airflow out of the vents that run along the inside of the hinge on the laptop as seen here:
When the lid is closed, there's a slight gap along the bottom that's used as an exit route for the hot air coming out of those vents as seen here:
If you're closing the lid, you should ensure that the entirety of this exit path along the bottom of the laptop is free from obstructions. That means not placing the bottom of laptop on a flat surface. Generally a vertical stand like this is employed if you want to operate the laptop with the lid closed and ensure ventilation remains adequate:
You should monitor the temperature sensors of your laptop to ensure your workloads don't push the unit beyond normal operating temperatures when you're using it with the lid close. You can use something like iStat Menus to keep an eye on critical, system operating parameters such as CPU use and the various temperature sensors in your MacBook to make sure they stay within their safe operating limits.
I have used 2010, 2013, 2016, and now 2018 MBP in 90% clamshell mode all the time.
They work ok BUT the rubber seal in your display lid will deteriorate. They will become sticky and can be annoying sometimes as some flakes will fall off.